c++ - CVcapture From 2 WebCams -


i taking input camera. more clear added photo: 2 cameras connected on same usb port enter image description here

with opencv following :

#define camleft 2 #define camright 0 #define win_l "win_l" #define win_r "win_r"  int main(int argc, const char * argv[]) {    videocapture capleft(camleft);    bool opened = capleft.isopened();    if(!opened /*|| !capright.isopened()*/)  // check if succeeded       return -1;     mat edges;    namedwindow(win_l,1);    for(;;)    {        mat framel;        mat framer;        capleft >> framel; // new frame camera        cvtcolor(framel, edges, cv_rgb2rgba);        imshow(win_l, edges);          if(waitkey(30) >= 0) break;    }    return 0; } 

so creating window named "win_l" stands window left , process video capture. works well. upgraded code support camera this:

int main(int argc, const char * argv[]) {     videocapture capleft(camleft);     videocapture capright(camright);     bool opened = capleft.isopened();     if(!opened /*|| !capright.isopened()*/)  // check if succeeded         return -1;      mat edges;     namedwindow(win_l,1);     namedwindow(win_r,1);     for(;;)     {         mat framel;         mat framer;         capleft >> framel; // new frame camera         cvtcolor(framel, edges, cv_rgb2rgba);         imshow(win_l, edges);         imshow(win_r, edges);         if(waitkey(30) >= 0) break;     }     return 0; } 

but don't see debugger hit line: bool opened.... correct way take capture 2 cameras?

i suspect usb bandwidth allocating problem. not sure if cause though, case 2 separate camera individual usb cable each.

but still, give shot. methods overcome problem: 1)put sleep(ms) in between lines of capture line. 2)use lower resolution reduce bandwidth used each camera. 3)use mjpeg format(compressed frames).

edit:

i came across website, webcam , usb drivers, thought might read it.

anyway, not sure if both cameras able run concurrently each other through 1 usb port , reason mentioned(i forgotten it. bad):

usb: universal serial bus, name suggest, serial data transmission, meaning, can send data 1 device to/and computer.

what happening in code deadlock, causing program not progress, on 1 camera.

2 reasons causes this:

1)i suspect driver each camera consistently overwriting each other, sending i/o request packet (irp), , "pipe" keeps on receiving , processing each request, , system keep deallocating each resource after allocated. goes on , on.

2)there starvation 2nd camera, if not allocated resource, program cannot progress. hence system stuck in loop 2nd camera keep requesting resource.

however, weird if invented 2 webcam using single serial bus when each camera needs channel/pipe of it's own communicate system. maybe check manufacturer straight? maybe came workaround, hence invented camera?

if not, purpose invention pretty redundant. can think of security purpose, 1 configured night view , 1 configured day view.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -