-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.cpp
59 lines (45 loc) · 1.07 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include "ffmpegdecoder.h"
class ImageProc
{
public:
ImageProc(){}
~ImageProc(){}
void process(FFmpegDecoder& decoder);
};
void ImageProc::process(FFmpegDecoder &decoder)
{
while(decoder.isConncected())
{
cv::Mat src;
decoder.mtx.lock();
if(!decoder.decodedImgBuf.empty())
{
src = decoder.decodedImgBuf.front().clone();
decoder.decodedImgBuf.pop_front();
// std::cout <<"img buffer size = "<< decoder.decodedImgBuf.size() << std::endl;
}
decoder.mtx.unlock();
if(!src.empty())
{
//do your stuff...
//
cv::imshow("src", src);
cv::waitKey(10);
src.release();
}
}
}
int main()
{
FFmpegDecoder decoder("your rstp address");
decoder.connect();
if(decoder.isConncected())
{
ImageProc imgProc;
std::thread t1{&FFmpegDecoder::decode, &decoder};
imgProc.process(decoder);
t1.join();
}
return 0;
}