kyamagu / mexopencv

Collection and a development kit of matlab mex functions for OpenCV library
http://kyamagu.github.io/mexopencv
Other
661 stars 319 forks source link

video capture with PointGrey camera #364

Closed eghbalhosseini closed 6 years ago

eghbalhosseini commented 7 years ago

Hi I have installed mexopencv on windows with matlab 2017b, but when I run the test I get the following errors

===== Incomplete: TestVideoWriter.test_2 =====
Error using TestVideoWriter.test_2 (line 41)
codecs

Error in UnitTest>testcase_run (line 456)
                feval(t);

Error in UnitTest>testsuite_run (line 421)
        status = testcase_run(tests{i}, opts);

Error in UnitTest (line 79)
    [results, passed] = testsuite_run(tests, opts);
amroamroamro commented 7 years ago

That's by design, each test result can be either pass, fail, or skip. Notice the summary printed at the end, something like:

Totals:
  1359 Passed, 1 Failed, 34 Incomplete
  Elapsed time is 90.348746 seconds.

So you should only worry about the failed ones, ignore the skipped ones...

This particular test is skipped and marked incomplete. Reason is it might depend on external codecs being installed. For example I don't think you can create WMV videos in Linux/Mac platforms using cv.VideoWriter.

https://github.com/kyamagu/mexopencv/blob/master/test/unit_tests/TestVideoWriter.m#L37-L73

amroamroamro commented 7 years ago

FYI, personally I use the K-Lite Mega Codec Pack for all my codec needs on Windows. In addition to the usual decoders, this includes encoders like XviD, x264, etc.

eghbalhosseini commented 7 years ago

Thanks, I am trying to get the video capture to recognize my PointGrey camera in Matlab, I am using windows 10. but when I run the read command I either get a empty matrix or the following error

Unexpected Standard exception from MEX file.
What() is:bad allocation
..

Error in cv.VideoCapture/open (line 292)
            successFlag = VideoCapture_(this.id, 'open', index, varargin{:});

Error in cv.VideoCapture (line 186)
                this.open(0);
amroamroamro commented 7 years ago

I'm not familiar with such cameras, I only ever used generic webcams in OpenCV. Did you try to specify a suitable backend API in the call? Something like:

cap = cv.VideoCapture(0, 'API','DirectShow')

or

cap = cv.VideoCapture(0, 'API','FireWire')

See the docs for the full list of backends.

help cv.VideoCapture
help cv.VideoCapture.open

The opencv videoio module is a really wrapper around I/O interfaces provided by either the operating system (think DirectShow and Video4Linux) or third-party drivers (OpenNI, Ximea, etc.). Note that these must be enabled at compile-time when you're building opencv from source. Run cv.getBuildInformation() to know which ones are enabled in your build.

If the generic interface does not work, and your camera model is not on the supported list, it probably means it uses a custom protocol and you have to use whatever SDK or API provided by the camera manufacturer.

This is explained in this opencv page: https://docs.opencv.org/3.3.0/d0/da7/videoio_overview.html


I did a quick search online for PointGrey cameras, and I found this example:

https://gist.github.com/kevinhughes27/5543668

It shows how to use the FlyCapture SDK to grab frames and convert the buffers to cv::Mat format. Obviously this is not included in mexopencv, and you'll have to write a custom MEX-file to work inside MATLAB.


You should try asking on OpenCV Answers website, you'll probably get better help about this..

amroamroamro commented 7 years ago

Not opencv related, but if you have access to the Image Acquisition Toolbox, they have support for various camera hardwares, including yours: https://www.mathworks.com/hardware-support/point-grey-camera.html