diff --git a/developers/opencv.md b/developers/opencv.md index 63eca72d..2971a606 100644 --- a/developers/opencv.md +++ b/developers/opencv.md @@ -224,17 +224,13 @@ if __name__ == '__main__': * BlueRov video capture example * Based on: * https://stackoverflow.com/questions/10403588/adding-opencv-processing-to-gstreamer-application + * Should be compiled with: g++ -g main.cpp `pkg-config --cflags --libs opencv4 gstreamer-1.0 gstreamer-app-1.0` -o example && ./example */ - -// Include atomic std library #include - -// Include gstreamer library +#include #include #include - -// Include OpenCV library -#include +#include // Share frame between main loop and gstreamer callback std::atomic atomicFrame; @@ -338,8 +334,8 @@ int main(int argc, char *argv[]) { gchar *descr = g_strdup( "udpsrc port=5600 " - "! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! avdec_h264 " - "! decodebin ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert " + "! application/x-rtp, payload=96 ! rtph264depay ! avdec_h264 " + "! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert " "! appsink name=sink emit-signals=true sync=false max-buffers=1 drop=true" ); @@ -378,9 +374,9 @@ int main(int argc, char *argv[]) { while(1) { g_main_iteration(false); - cv::Mat* frame = atomicFrame.load(); + const cv::Mat* frame = atomicFrame.exchange(nullptr); if(frame) { - cv::imshow("Frame", atomicFrame.load()[0]); + cv::imshow("Frame", *frame); cv::waitKey(30); } }