0

I just buy this : https://www.amazon.fr/gp/product/B08CGVSRQV/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 … I own a gopro3 and I would like to use it as webcam and work on it with opencv.

My system: gopro3 => microHDMI to HDMI => HDMI to USB3 (my purchase above) => my computer.

On Ubuntu, with this basic program:

#include <iostream>
#include <opencv4/opencv2/opencv.hpp>
#include <opencv4/opencv2/videoio.hpp>

using namespace cv;

int main() {
    VideoCapture vid(0);
    if (!vid.isOpened()) {...}

    Mat frame;
    for(;;) {
        vid >> frame; // get a new frame from camera
        imshow("edges", frame);
        if (waitKey(30) >= 0) break;
    }
    vid.release(); destroyAllWindows(); return 0;
}

A little window appears, about 800/600, and everything ok, good latence, good fps, bad quality but nothing strange. If I force 1920/1080:

vid.set(3, 1920);
vid.set(4, 1080);

I can see my video with a latency of about 1 second and maybe 5 fps;

I thought, maybe I have a problem with USB3 (for capture HDMI), but I try on "guvcview" which is limited to 30fps and everything ok (latency, fps, quality).

I don't know what to do to read my gopro with 1920/1080/60 with opencv (30fps should be good enough). Gopro is able to do 1920/1080/60, next cable too, capture card too, Ubuntu too ...

And maybe the problem is not opencv but Ubuntu configuration.

Any Idea ?

q7frkz
  • 13
  • 7

1 Answers1

0

I had the same Problem but on Windows. Specifying Video capture to use DSHOW solved the problem for me

cv::VideoCapture cap(0 + cv::CAP_DSHOW);

But unfortunadely as far as i know DSHOW is only for windows. But maybe this is a hind and you have to specify another API to use for reading the video stream.

orser
  • 134
  • 3
  • no, vid.isOpened() failed. Seems strange cause cv::CAP_DHOW = 700, and it is (0, cv::CAP_DSHOW) not "+", but thanks I look at this – q7frkz Nov 21 '20 at 20:31
  • Itried many API preference and it seems maybe I shoould compile opencv with gstreamer but i dont know and i only find python opencv and not c++ – q7frkz Nov 21 '20 at 21:10
  • You can clone OpenCV on GitHub and compile it yourself with CMake. That way you can specify how it should be compiled and enable different packages in CMake. The compiled downloadable version of OpenCV has only a limited amount of packages compiled – orser Nov 23 '20 at 18:06