introlab / find-object

Find-Object project
http://introlab.github.io/find-object/
BSD 3-Clause "New" or "Revised" License
448 stars 189 forks source link

Cannot open video file #53

Open johnnych7027 opened 6 years ago

johnnych7027 commented 6 years ago

Hi! Your Repo is awesome, thank's a lot! But I have problems, when I try to upload a video file. I chose: Camera from video file. What could be the problem?

mediaPath parameter value: D:/vid.mp4 videoFormats parameter value: .avi .m4v *.mp4 error text: [ WARN] Camera: Cannot open file "D:/vid.mp4". If you want to disable loading automatically this video file, clear the Camera/mediaPath parameter. By default, webcam will be used instead of the file. opencv ver: 3.4.0 release: Find-Object-0.6.0-win64.exe

matlabbe commented 6 years ago

Well, it depends on how it is encoded and the codec built in OpenCV dlls included in Find-Object. If the codec is not supported, it will fail. If you are able to read the file with your installed OpenCV version (find-object uses cv::VideoCapture to read video files), you may try to copy dlls over those in find-object folder. Otherwise, you would have to build find-object from source to link correctly to your OpenCV installation.

If you have a sample video to share, I could try to see if updating the binaries to more recent OpenCV would solve the problem.

Cheers, Mathieu

johnnych7027 commented 6 years ago

Thanks a lot, Mathieu! I tried to convert the original video with the codec X264 to other codecs (XVID, X265 ...), but it did not help. It seems that I'm doing something wrong. https://drive.google.com/open?id=1dhlrZb0_bn4uxvPK9SEoAOHaqfb1-E_C

One more question, I try to use your software to understand what combination of detectors and descriptors is better to use for real-time systems (for the needs of augmented reality). That’s why it is important to test various combinations of detectors and descriptors on one roller. I need to get the solution unchanged to scale and rotation with the best accuracy and speed ratio. I managed to detect an object from the video stream of webcam only with the help of a combination of SIFT / SIFT. But the latency leaves much to be desired. What combinations should I pay attention to?

matlabbe commented 6 years ago

I just released new binaires (0.6.2) with OpenCV 3.4.1. It should open your video (working here).

ORB is also scale/rotation invariant. It may not give as many good correspondences than SIFT or SURF, but it is a lot faster. Otherwise, read papers related to all detectors/descriptors for more info (links would be found in OpenCV documentation).

cheers, Mathieu

matlabbe commented 5 years ago

OpenCV's VideoCapture object is used to read video files. You may try this simple python example ("Playing Video from file" section) to see if OpenCV can read the file: https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html

In Find-Object, the video capture is initialized here: https://github.com/introlab/find-object/blob/5047163c09df5515bc505341c279045c8d9c503c/src/Camera.cpp#L234

cheers, Mathieu

matlabbe commented 5 years ago

Default dependencies are not always the same on Windows and Linux. When you built on Linux, probably ffmpeg has been detected as dependency and built with its support. On Windows, OpenCV may be built by default with only limited video support from Windows API.

For example, you can try the latest artifacts: https://ci.appveyor.com/project/matlabbe/find-object/branch/master/artifacts They are built with http://kent.dl.sourceforge.net/project/opencvlibrary/opencv-win/3.4.1/opencv-3.4.1-vc14_vc15.exe

cheers, Mathieu

matlabbe commented 5 years ago

I also tried the latest artifact you suggested, not just it is not able to load a video

That version is using the officially released OpenCV version, so if your video cannot be loaded with it, you may ask on OpenCV repo why their binaries cannot open your video. My guess is that they cannot bundle those dependencies because of some license issues: https://github.com/opencv/opencv/issues/10496

What we can do here is to rebuild OpenCV from source with some dependencies (ffmpeg?) that support the codec used in your video. For that, it will be easier if you can share a sample of your video. We can then know if there is an OpenCV's dependency that can be used under Windows to support it. Otherwise, you would have to convert the video to some more general codecs that can be read by the OpenCV official released version... or use linux as you did.

cheers, Mathieu