No Video from Camera (OpenCV 2.2) (Bug #735)
Description
Platform: Windows 7 64 bit Visual Studio 2010 Professional
Problem: Unable to get videos from Webcam after an upgrade from OpenCV 2.1. It shows only a black or grey screen.
Tested with both 32 bit binary package and 64 bit manually compiled libraries, but to no avail.
It works fine with OpenCV 2.1 libraries.
Code:
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
VideoCapture capture(0);
if (!capture.isOpened())
capture.open(0);
if (!capture.isOpened()) {
cerr << "Failed to open a video device\n" << endl;
return 1;
}
string window_name = "Camera Test";
cout << "press q or esc to quit" << endl;
namedWindow(window_name, CV_WINDOW_KEEPRATIO);
Mat frame;
for (;;) {
capture >> frame;
if (frame.empty())
continue;
imshow(window_name, frame);
char key = (char)waitKey(5);
switch (key) {
case 'q':
case 'Q':
case 27: //escape key
return 0;
default:
break;
}
}
}
Related issues
duplicated by Bug #763: HAVE_VIDEOINPUT not set for highgui/win32/vs2008 by cmake | Done | |||
duplicated by Bug #750: camera black screen in opencv2.2 | Done |
Associated revisions
Merge pull request #735 from jet47:fix-windows-issues
History
Updated by 铖 许 over 14 years ago
I have tried to use the patch above. And find out that it works fine.
Updated by Kian Yew Siaw over 14 years ago
I got a linker error after applying the patch:
Creating library C:/Users/SKY/Desktop/OpenCV2.2/lib/Release/opencv_highgui220.lib and object C:/Users/SKY/Desktop/OpenCV2.2/lib/Release/opencv_highgui220.exp 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_RGB24 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_AYUV 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_Y211 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_Y41P 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_Y411 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_YVU9 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_YV12 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_UYVY 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_IYUV 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_YUYV 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_YVYU 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_YUY2 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_RGB565 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_RGB555 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIASUBTYPE_RGB32 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIATYPE_Video 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IAMAnalogVideoDecoder 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_VideoInputDeviceCategory 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_SystemDeviceEnum 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_ICreateDevEnum 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IAMVideoProcAmp 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IAMCameraControl 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IMediaFilter 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_NullRenderer 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol FORMAT_VideoInfo 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_ISampleGrabber 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_SampleGrabber 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IBaseFilter 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol PIN_CATEGORY_PREVIEW 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IAMStreamConfig 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IMediaControl 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_FilterGraph 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IGraphBuilder 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol CLSID_CaptureGraphBuilder2 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_ICaptureGraphBuilder2 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol PIN_CATEGORY_CAPTURE 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol MEDIATYPE_Interleaved 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol LOOK_UPSTREAM_ONLY 8>videoInput64.lib(videoInput.obj) : error LNK2001: unresolved external symbol IID_IAMCrossbar 8>C:\Users\SKY\Desktop\OpenCV2.2\bin\Release\opencv_highgui220.dll : fatal error LNK1120: 39 unresolved externals 8> 8>Build FAILED.
Updated by 铖 许 over 14 years ago
Please ignore my patch, it seems works only in 64bit Windows, which happened to be my case.
Updated by Kian Yew Siaw over 14 years ago
Your patch actually works with Win32 configuration even in 64bit Window, which is my case too. The errors arose when I configured to compile in x64.
Updated by vasek opekar about 14 years ago
Hi all,
I added alternative no_video_from_camera.path for opencv\modules\highgui\src\precomp.hpp
seems to me to be more similar to the other precomp.hpp files in the opencv directory tree.
was tested only on win32/vista.
Updated by Vadim Pisarevsky about 14 years ago
thanks! your patch has been applied in r4400 (https://code.opencv.org/svn/opencv/branches/2.2/opencv)
- Status changed from Open to Done
- (deleted custom field) set to fixed
Updated by Frankie Fong about 14 years ago
Hi,
I have been working with OpenCV 2.2 release with VS2008 Express on WinXP without much problem. I am moving the code to new machine running Windows 7 (Core i5). I installed Visual C++ Express 2010 on the Win7 machine. I am seeing this exact same reported problem. So I applied the change of r4400. I redo CMake and Rebuild the Solution. And I am still getting the link error for opencv_highgui220d.dll. Am I missing something?
I took the liberty of re-opening this bug. Hope you don't mind.
- Status changed from Done to Cancelled
- (deleted custom field) deleted (
fixed)
Updated by Frankie Fong about 14 years ago
I forgot to mention - I am building x64 bit target.
Updated by Hae Yong Kim about 14 years ago
I applied the patch r4400 and I could successfully compile Opencv 2.2 using visual c++ express 2008.
However, when I try to compile it using gcc 4.4.0 (that comes with Qt), I get the link error below. I am trying to build 32 bits target in Windows 7 (64 bits).
(...)
[ 71%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grf
mt_tiff.obj
Linking CXX shared library ..\..\bin\libopencv_highgui220.dll
Creating library file: ..\..\lib\libopencv_highgui220.dll.a
c:\OpenCV22\modules\highgui\..\..\3rdparty\lib/libvideoInput.a(videoInput.o):vid
eoInput.cpp:(.text+0xee): undefined reference to @+gxx_personality_sj0'
c:\OpenCV22\modules\highgui\..\..\3rdparty\lib/libvideoInput.a(videoInput.o):vid
eoInput.cpp:(.text+0x104): undefined reference to @_Unwind_SjLj_Register'
c:\OpenCV22\modules\highgui\..\..\3rdparty\lib/libvideoInput.a(videoInput.o):vid
eoInput.cpp:(.text+0x2a6): undefined reference to @_Unwind_SjLj_Unregister'
c:\OpenCV22\modules\highgui\..\..\3rdparty\lib/libvideoInput.a(videoInput.o):vid
eoInput.cpp:(.text+0x2d4): undefined reference to @_Unwind_SjLj_Resume'
(...)
Updated by Hae Yong Kim about 14 years ago
I forgot to mention - I successfully compiled OpenCV2.2 using gcc in Windows7-64bits WITHOUT the patch r4400. But in this case webcam does not work.
Updated by Vadim Pisarevsky over 13 years ago
hopefully, the latest trunk version (soon to become OpenCV 2.3) resolves the problem. We now put videoInput source code right into highgui, so there should not be linking errors anymore.
- Status changed from Cancelled to Done
- (deleted custom field) set to fixed
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-camera