Cannot connect to webcam with opencv C++ -


i working on project , found out can't connect webcam anymore! thing is, working fine in windows x64, when changed project x32 started having problems. when run code, behaves random! 70% of time goes capture = cvcapturefromcam(0); command never come out of command, 25% of time finishes command capture still remains 0, , 5% of time works fine (sometimes when restart windows). i'm sure webcam connected correctly because can see webcam movie maker , see webcam getting video fine (i close movie maker before run program, nothing else connected it!)

i have simple code said, isn't working correctly in line 2. causing problem? note: opencv version 2.4.2 being used.

#include <opencv2\opencv.hpp> #include <iostream>  using namespace cv; using namespace std;  int main() {     cvcapture* capture = 0;     capture = cvcapturefromcam(0);     sleep(1000);     int q;      cin>>q;     if(!capture)     {         printf("could not initialize capturing...\n");         return -1;     }      iplimage* frame = 0;     frame = cvqueryframe(capture);     cvshowimage("video", frame);     int c = cvwaitkey(20);       cvreleasecapture(&capture);     return 0; } 


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -