I have java code that reads radio signals via Bluetooth. I want to read different signals and each signal open webcam. I have four USB cameras if the code detect signal 1 it should open camera 1 if the code detect signal2 camera2 should opened and so on. I add the follwing code using opencv with eclipse:
if (this.isDigitalOn(1) == true)
{
CvCapture capture = opencv_highgui.cvCreateCameraCapture(0);
opencv_highgui.cvSetCaptureProperty(capture, opencv_highgui.CV_CAP_PROP_FRAME_HEIGHT, 500);
opencv_highgui.cvSetCaptureProperty(capture, opencv_highgui.CV_CAP_PROP_FRAME_WIDTH, 1000);
IplImage grabbedimage = opencv_highgui.cvQueryFrame(capture);
CanvasFrame frame = new CanvasFrame ("Webcam0");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
while(frame.isVisible() && (grabbedimage = opencv_highgui.cvQueryFrame(capture)) != null)
{
frame.showImage(grabbedimage);
}
}
else
if (this.isDigitalOn(2) == true)
{
CvCapture capture1 = opencv_highgui.cvCreateCameraCapture(1);
opencv_highgui.cvSetCaptureProperty(capture1, opencv_highgui.CV_CAP_PROP_FRAME_HEIGHT, 500);
opencv_highgui.cvSetCaptureProperty(capture1, opencv_highgui.CV_CAP_PROP_FRAME_WIDTH, 1000);
IplImage grabbedimage1 = opencv_highgui.cvQueryFrame(capture1);
CanvasFrame frame1 = new CanvasFrame ("Webcam1");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
while (frame1.isVisible() && (grabbedimage1 = opencv_highgui.cvQueryFrame(capture1)) != null)
{
frame1.showImage(grabbedimage1);
}
}
The code is working fine but can\t open more than one camera at the same time. Any ideas please?