I can embed OpenCV .DLLs and build my program in Visual Studio 2010, Debug mode, x64 platform using OpenCV 2.4.4 static libraries from C:\opencv244\build\x64\vc10\staticlib.
I use VideoCapture to load a video file and play it. Everything works fine when I open an uncompressed video file; But when I open a compressed video file (e.g. xvid), VideoCapture fails and can not load and open the video file. In this case if I put OpenCV .dll files near my program's .exe file, VideoCapture will work for the compressed video files too. But I have embedded OpenCV .dlls in the .exe file and I assume it has to be able to work fine without having OpenCV .dlls. Could you please let me know how can I resolve this issue?
Update:
Just now I noticed this issue will be resolved by only including opencv_ffmpeg244_64.dll near the program's .exe file. Other OpenCV .dlls will not be required to be present. So now the question will be: Is there any way to embed "opencv_ffmpeg244_64.dll" in the program's .exe file? (Albeith this one is not a big deal after all).
Related
I have a RTPS streaming camera. The stream works fine when I test it with VLC:
vlc -vvv rtsp://192.168.0.23:554/stream
However with openCV it does not open:
cv::VideoCapture capture;
bool ok = capture.open("rtsp://192.168.0.23:554/stream");
returns false.
What can be the reason?
I had a similar problem. In my case the dll starts with "opencv_ffmpeg" was missing in the run path.
If you are using OpenCV 4+ you need to copy the ffmpeg related dll and paste it next to your executable. For example I've built my OpenCV with the BUILD_opencv_world option and I have a file named opencv_videoio_ffmpeg430_64.dll in my bin folder in the my build directory. Without that file it won't open the stream and shows nothing.
When using the VideoCaptuer class with OpenCV 4, in C++, it does not work with RTSP streams.
you can do it by OpenCV and python as below:
import cv2
str1=cv2.VideoCapture("RTSP Address")
while True:
_,frame=str1.read()
cv2.imshow('SOMENAME',frame)
s=cv2.waitkey(0)
I built OpenCV (with mingw 4.9.2 # Win7Prof64) with
CMake switches for WITH_FFMPEG and WITH_DSHOW turned on.
When I access a movie file with VideoCapture (fileName) works fine (it uses ffmpeg backend then).
But VideoCapture (fileName, cv::CAP_DSHOW) doesn't work
(isOpened() returns false).
What is missing/ what do I do wrong?
Are there any kind of dshow libs/ dlls needed?
As to my duplicate in opencv forum ... cv::CAP_DSHOW is not implemented for files.
I (Win 7) followed Alternative method, for OpenCV 2.2 to configure codeblocks for opencv 2.4.4
I installed opencv and built it for my laptop using cmake.
However, after many many days and many attempts I was unsuccessful.
I extracted opencv 2.4.4 in c:/opencv and then build it in a folder I defined asbin. Bur, I do not seem to find the libraries and there are multiple include and opencv2 folder. It is very confusing. Here is a file tree of my c:/opencv/bin folder. Sorry, if this is too much information. Also, my lib files has .dll.a extension not just .dll
When I run a sample code with opencv, it show error that opencv could not be found.
Please help me to do the configuration correctly. You may post the list of files you have in your opencv folder? This is help me to know what do I expect.
You may use the following command if you wish.
DIR "Your OpenCV Dir" /B /S > "OutputFileDir\MyOpenCVTree.txt"
Finally, by Neol's help I could do it.
I exactly followed his post here
I was mistakenly thinking that vc10 (or vc9,vc11) can only be used when we need to use visual C++. (pardon my lack of knowledge).
I then added the dll files as shown in the post and the following figure.
At least the following "Hello World program" for opencv worked. (Of course you need to change the image path or put an image inside the folder where the cpp code is saved)
#include <highgui.h>
int main()
{
IplImage* img = cvLoadImage("android.jpg");
cvNamedWindow("Android", CV_WINDOW_AUTOSIZE);
cvShowImage("Android", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Android");
}
So I'm trying to write a video using the openCV videoWriter as such:
writer=cv.CreateVideoWriter(path+"test_output.avi",-1,fps,(W,H),1)
So instead of supplying the FOURCC I supplied -1 in order to see what codecs I have available.
Result was Microsoft RLE, Microsoft Video 1, Intel YUV, and Uncompressed.
The reason is that when configuring openCV using CMAKE for Visual Studio 10 x64, this is what I have in the video i/o:
Video I/O: DirectShow
Is there a way to switch this to FFMPEG? I know the ffmpeg dll is present in \3dparty\ffmpeg.
I looked for Cmake FFMPEG flags but found none whatsoever. The weird thing is in the CmakeLists.txt in the opencv root under the video section:
if(UNIX AND NOT APPLE)
<FFMPEG stuff>
elseif(WIN32)
status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
endif()
So it seems to me that opencv automatically switched to DirectShow and gives no choice of using FFMpeg.
Or rather can one upgrade Driectshow to support other formats such as Divx or h264?
Any ideas?
The answer your looking for is here and it works for the 32 bit and 64 bit configurations. I used this build of FFMPEG. http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z
1) Download OpenCV 2.3
2) Open the root CMakeLists.txt and insert the line set(HAVE_FFMPEG 1)
3) Download http://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-git-1aeb88b-win64-dev.7z (or the 32 bit build if u fancy it)
4) Edit avformat.h found in the ffmpeg include dir with #define INT64_C
5) Edit cap_ffmpeg_impl.hpp from the highgui project with #define snprintf _snprintf
6) in your highgui project properties under C/C++>Additional Include Directories add path of the include directory of FFMPEG you just downloaded
7)On the same property page under Linker>General>Additional Library Dependencies add the path of the lib directory of FFMPEG you just downloaded
8)On the same property page under Linker>Input>Additional dependencies add ALL the names of the libraries of ffmpeg found in lib (avformat.lib, avscale.lib, avcore.lib etc)
9) build the highgui project
10) Add the path of the .dll files that came with FFMPEG to the System Path environment variable.
That's it! 10 easy steps ;)
If you're still unable to compile OpenCV with FFMpeg support, the library that is linked on this blogpost provides a pretty good starting point for creating a windows-compatible FFMpeg wrapper: Making OpenCV-2.3 work with ffmpeg library and Microsoft Visual Studio 2010
I have similiar problem as was presented here, but with opencv_imgproc231.dll (opencv_core231.dll is loaded correctly in my case).
I installed OpenCV 2.3.1 and set environment variable PATH to foldres in "vc9\bin" folder. I added all OpenCvSharp dlls to references. When I run my c# program, it loads opencv_core231.dll correctly, but opencv_imgproc231.dll cant find (is in tha same directory as all opencv dlls). I tried copy opencv dlls to folder where is executable file, but it showed same error.
I did all what he did - C++ red. pack. 2008, 2010SP1, set PATHs, copy openCV dlls to folder, where is executable file - but nothing works, still DllNotFoundException for opencv_imgproc231.dll.
I have VS2008 and Windows 7 32bit.
My program contains only one row: "IplImage image = new IplImage(128, 128, BitDepth.U8, 1);".
Thanks for any advice.
Pavel.
I found this issue at google code http://code.google.com/p/opencvsharp/issues/detail?id=97
add tbb.dll (from opencv/build/common/tbb) to PATH or same folder of the executable works for me :)
Ok, I solved it. There is problem in precompiled openCV DLL. So if you have similar problem, recompile openCV and it will work. I dont why, but precompiled opencv_imgproc230.dll has 1579008 bytes and my recompiled opencv_imgproc230.dll has 1568768 bytes, but it works.