sarxos / webcam-capture

The goal of this project is to allow integrated or USB-connected webcams to be accessed directly from Java. Using provided libraries users are able to read camera images and detect motion. Main project consist of several sub projects - the root one, which contains required classes, build-in webcam driver compatible with Windows, Linux and Mac OS, which can stream images as fast as your camera can serve them (up to 50 FPS). Main project can be used standalone, but user is able to replace build-in driver with different one - such as OpenIMAJ, GStreamer, V4L4j, JMF, LTI-CIVIL, FMJ, etc.
http://webcam-capture.sarxos.pl
MIT License
2.25k stars 1.11k forks source link

Cannot identify '▒y▒Xp ▒▒ ▒(▒▒': 2, No such file or directory #314

Closed aaav19983008 closed 9 years ago

aaav19983008 commented 9 years ago

Hi, I'm trying to capture an image from Raspberry PI, using this code in java

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
import java.awt.Dimension;

public class FinchTest {

        public static void main(String[] args) throws IOException {

                // get default webcam and open it
                Webcam webcam = Webcam.getDefault();
                webcam.setViewSize(new Dimension(640,480));

                webcam.open(false);
                //webcam.open();

                // get image
                BufferedImage image = webcam.getImage();

                // save image to PNG file
                ImageIO.write(image, "PNG", new File("/home/pi/dev/FinchTest/PH.png"));
        }

}

I'm using these libraries

the operating system I'm using

Linux drswifty 3.18.6+ #1 PREEMPT Sat Feb 7 18:11:00 GMT 2015 armv6l GNU/Linux

this is the error log

2015-02-10 12:18:58 INFO  [main] com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
2015-02-10 12:18:58 DEBUG [webcam-discovery-service] com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver - Searching devices
2015-02-10 12:19:02 DEBUG [webcam-discovery-service] com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver - Found device Camera Board OV5647 /dev/video0
2015-02-10 12:19:02 DEBUG [main] com.github.sarxos.webcam.WebcamLock - Lock Webcam Camera Board OV5647 /dev/video0
2015-02-10 12:19:02 INFO  [atomic-processor-1] com.github.sarxos.webcam.ds.cgt.WebcamOpenTask - Opening webcam Camera Board OV5647 /dev/video0
2015-02-10 12:19:02 DEBUG [atomic-processor-1] com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Opening webcam device Camera Board OV5647 /dev/video0
2015-02-10 12:19:02 DEBUG [atomic-processor-1] com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice - Webcam device /dev/video0 starting session,
 size java.awt.Dimension[width=176,height=144]
Cannot identify '▒y▒Xp ▒▒ ▒(▒▒': 2, No such file or directory
2015-02-10 12:19:02 DEBUG [main] com.github.sarxos.webcam.WebcamLock - Unlock Webcam Camera Board OV5647 /dev/video0
2015-02-10 12:19:02 DEBUG [webcam-lock-[Camera Board OV5647 /dev/video0]] com.github.sarxos.webcam.WebcamLock - Lock updater has been interrupted
2015-02-10 12:19:02 DEBUG [main] com.github.sarxos.webcam.Webcam - Webcam exception when opening
com.github.sarxos.webcam.WebcamException: Cannot execute task
        at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.process(WebcamProcessor.java:72) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.WebcamProcessor.process(WebcamProcessor.java:140) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.WebcamTask.process(WebcamTask.java:46) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.open(WebcamOpenTask.java:20) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.Webcam.open(Webcam.java:271) [webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.Webcam.open(Webcam.java:232) [webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at FinchTest.main(FinchTest.java:18) [FinchTest/:na]
Caused by: com.github.sarxos.webcam.WebcamException: Cannot start native grabber!
        at com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice.open(WebcamDefaultDevice.java:335) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.handle(WebcamOpenTask.java:38) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:81) ~[webcam-capture-0.3.11-20141227.105512-4.jar:na]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) ~[na:1.8.0-ea]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) ~[na:1.8.0-ea]
        at java.lang.Thread.run(Thread.java:722) ~[na:1.8.0-ea]
Exception in thread "main" com.github.sarxos.webcam.WebcamException: Cannot execute task
        at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.process(WebcamProcessor.java:72)
        at com.github.sarxos.webcam.WebcamProcessor.process(WebcamProcessor.java:140)
        at com.github.sarxos.webcam.WebcamTask.process(WebcamTask.java:46)
        at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.open(WebcamOpenTask.java:20)
        at com.github.sarxos.webcam.Webcam.open(Webcam.java:271)
        at com.github.sarxos.webcam.Webcam.open(Webcam.java:232)
        at FinchTest.main(FinchTest.java:18)
Caused by: com.github.sarxos.webcam.WebcamException: Cannot start native grabber!
        at com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice.open(WebcamDefaultDevice.java:335)
        at com.github.sarxos.webcam.ds.cgt.WebcamOpenTask.handle(WebcamOpenTask.java:38)
        at com.github.sarxos.webcam.WebcamProcessor$AtomicProcessor.run(WebcamProcessor.java:81)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

I'm accessing raspberry pi over shh(putty) using wifi, I have solved a lot of error to come at this stage, out of clue now, no idea how to solve it, if you look at the error log ( Cannot identify '▒y▒Xp ▒▒ ▒(▒▒': ), I have no idea what this part is telling. Can you please help me, this is part of my university project, any help would be highly appreciated.

amroamer commented 9 years ago

@aaav19983008 when you try to run the above code, is your webcam running using another application ?

sarxos commented 9 years ago

Hi @aaav19983008,

I suppose this error:

Cannot identify '▒y▒Xp ▒▒ ▒(▒▒': 2, No such file or directory

Comes from:

http://sourceforge.net/p/openimaj/code/HEAD/tree/trunk/hardware/core-video-capture/src-native/linux/capture.cpp line 577.

However, the root cause, i.e. why is device name ▒y▒Xp ▒▒ ▒(▒▒ instead of /dev/video0 is an unknown to me. It's too low level for me to find out what may be wrong.

I'm trying to find out if gstreamer or vlc can be used instead.

sarxos commented 9 years ago

@aaav19983008,

I managed to run the following stack on my RasPi. It works on top of the VLC instead of OpenIMAJ. I hope you can use this configuration to w/a your issue, but please note that FPS rate of this solution is not very impressive.

pi@raspberrypi ~ $ sudo apt-get install vlc
pi@raspberrypi ~ $ vlc --version
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
VLC version 2.0.3 Twoflower (2.0.2-93-g77aa89e)
Compiled by buildd on build01.raspbian.lan (Jul  7 2014 21:46:39)
Compiler: gcc version 4.6.3 (Debian 4.6.3-14+rpi1) 

Artifacts:

As I stated, the FPS is not impressive, and it could be potentially improved by magnitude of tenth just by using Webcam Capture API v0.3.11 (snapshot), but I checked it on RasPi and all the images in such configuration are black and application does not want to stop.

public class WebcamPanelExample {

    static {
        Webcam.setDriver(new VlcjDriver());
    }

    public static void main(String[] args) throws InterruptedException {

        Webcam webcam = Webcam.getWebcams().get(0);
        webcam.setViewSize(WebcamResolution.VGA.getSize());

        WebcamPanel panel = new WebcamPanel(webcam);
        panel.setFPSDisplayed(true);
        panel.setImageSizeDisplayed(true);

        JFrame window = new JFrame("Webcam Panel");
        window.add(panel);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.pack();
        window.setVisible(true);
    }
}

raspipanel

aaav19983008 commented 9 years ago

Thank's a lot @amroamer and @sarxos for the responses, :)

@amroamer I'm using the camera comes with Raspberry PI or created for Raspberry PI only, as a result I don't think other program using the camera. (That's what I understand)

@sarxos Since I don't have that much deep knowledge about all these stuff, so I have no idea why the device name is ▒y▒Xp ▒▒ ▒(▒▒ instead of /dev/video0, if you please can tell me how to change the name I will change that.

And just to give you a little more overview, my project is with Finch Robot, at this stage I'm trying to take a picture successfully, because I have to do image processing. I'm trying everything you have suggested, will be back. :)

sarxos commented 9 years ago

@aaav19983008,

You wrote that you are using "the camera comes with Raspberry PI or created for Raspberry PI only". Are you referring to Raspberry Pi camera module, like this for example?

http://www.raspberrypi.org/products/camera-module/

Or you are referring to some other USB camera (or rather UVC device) that you bought together with Pi?

sarxos commented 9 years ago

I'm asking because Webcam Capture API never supported Raspberry Pi camera module. This is because camera module works on top of MMAL which is not UVC compliant. For the camera module you can use raspistill tool to get the image.

Things are different for USB cameras. Those should work in 99% cases.

In regards to your question. The camera name cannot be changed. The /dev/videoN files are created automatically by the OS whenever new device id detected.

aaav19983008 commented 9 years ago

@sarxos I'm referring to Raspberry Pi camera module, and what you said that means I'm trying in a wrong way to make things work. :( if you please tell me little more about raspistill tool, or just provide a link i need to have a look that how to implement that one, if that will take long time to work with I will manage USB camera, because I'm already trying to work with Webcam capture.

sarxos commented 9 years ago

@aaav19983008,

It seems like there was some development effort to make RasPi Cam usable via V4L (link) but I never tested if this solution may work or not since I do not have my own camera module.

http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16

In regards to the raspistill and raspivid, the first one is to capture image from camera module, and second one to record a movie.

Here is some good resource. Both tools are described with options they expose. If this is not enough then you

http://elinux.org/Rpi_Camera_Module

If you would like to stay with Java in your project, then you can simple use ProcessBuilder to run raspistill whenever you need new image. You can save the output to file or pre-created named pipe. By using named pipe you will be able to stream frames in the same way as you would do with the webcam, so from the Java perspective nothing would change actually. Instead of ProcessBuilder you can also use signal mode (-s) with infinity time (-t 0) to capture image in response to SIGUSR1 (e.g. kill -SIGUSR1 <pid>).

There is no plain Java API that will act like a nice proxy to raspistill tool, but wrapping it in Java is IMHO a hundred times better option than writing own interface from scratch using MMAL. Everything is doable, the resources are available, so you will not have to reinvent the wheel, but everything depends on your needs (e.g. if you need high or low FPS, etc).

aaav19983008 commented 9 years ago

@sarxos Thank you very much for the information you have provided, :) . I will try that.

Before that I have managed a webcam today (HP Webcam HD 2300), I have tried with this code

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.ds.vlcj.VlcjDriver;
import com.github.sarxos.webcam.WebcamResolution;
import com.github.sarxos.webcam.WebcamPanel;
import javax.swing.JFrame;

public class FinchTest {

        static {
        Webcam.setDriver(new VlcjDriver());
        }

        public static void main(String[] args) throws InterruptedException {

        Webcam webcam = Webcam.getWebcams().get(0);
        webcam.setViewSize(WebcamResolution.VGA.getSize());

        WebcamPanel panel = new WebcamPanel(webcam);
        panel.setFPSDisplayed(true);
        panel.setImageSizeDisplayed(true);

        JFrame window = new JFrame("Webcam Panel");
        window.add(panel);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.pack();
        window.setVisible(true);
    }
}

and I have got this error

03:25:11.394 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver VlcjDriver
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:603)
        at java.util.ArrayList.get(ArrayList.java:381)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1225)
        at FinchTest.main(FinchTest.java:20)

I believe this line (Webcam webcam = Webcam.getWebcams().get(0);) is responsible.


then I have modified code little bit

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamResolution;
import com.github.sarxos.webcam.WebcamPanel;
import javax.swing.JFrame;

public class FinchTest {

        public static void main(String[] args) throws InterruptedException {

        Webcam webcam = Webcam.getDefault();
        webcam.setViewSize(WebcamResolution.VGA.getSize());

        WebcamPanel panel = new WebcamPanel(webcam);
        panel.setFPSDisplayed(true);
        panel.setImageSizeDisplayed(true);

        JFrame window = new JFrame("Webcam Panel");
        window.add(panel);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.pack();
        window.setVisible(true);
    }
}

And I got this error

03:11:59.791 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
03:12:00.014 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
03:12:04.634 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
03:12:04.719 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new resolution 640x480
03:12:07.568 [main] DEBUG com.github.sarxos.webcam.WebcamPanel - Starting panel rendering and trying to open attached webcam
03:12:07.605 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam HP Webcam HD 2300 /dev/video0
03:12:07.666 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam HP Webcam HD 2300 /dev/video0
03:12:07.669 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device HP Webcam HD 2300 /dev/video0
03:12:07.674 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device /dev/video0 starting session, size java.awt.Dimension[width=640,height=480]
warning: error opening device
03:12:07.723 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
Timeout!
error: Connection timed outfd: 23
libv4l2: error mmapping buffer 0: No such device
03:12:58.744 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
03:13:11.865 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
** console hanged here and I have forced to terminate the program

Moreover I have tried with these code, where I didn't use VLC

---------------------------1

import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;

public class FinchTest {

    public static void main(String[] args) throws IOException {
    Webcam webcam = Webcam.getDefault();
    webcam.open();
    ImageIO.write(webcam.getImage(), "PNG", new File("ph2.png"));

    }
}

I got this error

01:31:39.978 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
01:31:40.174 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
01:31:45.174 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
01:31:45.232 [main] INFO  com.github.sarxos.webcam.WebcamLock - Locking mechanism has been disabled in Webcam HP Webcam HD 2300 /dev/video0
01:31:45.253 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam HP Webcam HD 2300 /dev/video0
01:31:45.256 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device HP Webcam HD 2300 /dev/video0
01:31:45.259 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device /dev/video0 starting session, size java.awt.Dimension[width=176,height=144]
warning: error opening device
warning: error opening device
01:31:57.806 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
01:32:00.265 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
01:33:46.815 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
Killed

-----------------------------2

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;

public class FinchTest {

    public static void main(String[] args) throws IOException {

        // get default webcam and open it
        Webcam webcam = Webcam.getDefault();
        webcam.getLock().disable();

        webcam.setViewSize(new Dimension(640,480));

            webcam.open(false);
        //webcam.open();

        // get image
        BufferedImage image = webcam.getImage();

        // save image to PNG file
        ImageIO.write(image, "PNG", new File("test.png"));
    }
}

and I got this error

02:02:56.230 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
02:02:56.427 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
02:03:01.295 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
02:03:01.380 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam HP Webcam HD 2300 /dev/video0
02:03:01.419 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam HP Webcam HD 2300 /dev/video0
02:03:01.422 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device HP Webcam HD 2300 /dev/video0
02:03:01.427 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device /dev/video0 starting session, size java.awt.Dimension[width=176,height=144]
warning: error opening device
warning: error opening device
02:03:03.324 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
02:03:09.137 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
02:05:35.052 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
02:06:13.153 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device com.github.sarxos.webcam.ds.buildin.WebcamDefaultDevice@10278c5 is now open
02:06:42.396 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open HP Webcam HD 2300 /dev/video0
warning: error opening device
02:07:21.793 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error
libv4l2: error dequeuing buf: Input/output error

02:22:46.250 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
02:22:46.512 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
02:22:51.553 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
02:22:51.624 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam HP Webcam HD 2300 /dev/video0
02:22:52.351 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam HP Webcam HD 2300 /dev/video0
02:22:52.354 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device HP Webcam HD 2300 /dev/video0
02:22:52.372 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device /dev/video0 starting session, size java.awt.Dimension[width=176,height=144]
warning: error opening device
warning: error opening device
02:22:55.685 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
02:23:01.977 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
02:24:29.077 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
Killed

Can you please give me some idea, I'm desperate to make it work.

sarxos commented 9 years ago

@aaav19983008,

Today after I'm back at home I will commit changes in webcam-capture-driver-v4l4j which I verified to be the most stable on the RasPi, however, from what I see in the logs, the default driver should work in your case because it calls libv4l2 as expected.

Why are you releasing the lock?

 webcam.getLock().disable();

If you experience problems with the lock it means that the other Java process is using this webcam. If this is the case, then you will not be able to open it again (this may cause warning: error opening device). You first need to kill other process (grep your Java process and kill it, the <pid> is a process ID).

$ ps -ef | grep -i java
$ kill -9 <pid>

This is strange:

libv4l2: error dequeuing buf: Input/output error

I read people having trouble with some USB cameras on RasPi, however, according to this wiki page your camera should work fine.

Can you please install fswebcam and verify if you can capture the image? In case the fswebcam works well, you can switch to webcam-capture-driver-fswebcam to start, and then debug the problem deeper to make use either default or V4L4J driver.

aaav19983008 commented 9 years ago

@sarxos

I don't really remember why I was releasing the lock! But still, even without releasing the lock the problem is same,

07:52:28.590 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
07:52:28.783 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
07:52:33.805 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
07:52:33.884 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam HP Webcam HD 2300 /dev/video0
07:52:33.950 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam HP Webcam HD 2300 /dev/video0
07:52:33.953 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Opening webcam device HP Webcam HD 2300 /dev/video0
07:52:33.958 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device /dev/video0 starting session, size java.awt.Dimension[width=176,height=144]
warning: error opening device
warning: error opening device
07:52:44.941 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
07:52:50.959 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Webcam device session started
07:53:03.064 [atomic-processor-1] DEBUG c.g.s.w.d.b.WebcamDefaultDevice - Initialize buffer
Killed

by using this command "ps -ef | grep -i java" what I found is

pi@drswifty ~/dev/FinchTest $ ps -ef | grep -i java
pi        2724  2635  0 07:44 pts/0    00:00:00 grep --color=auto -i java

and if I execute "kill -9 2635", it shuts down Putty immediately.

I have Installed fswebcam, this link http://www.raspberrypi.org/documentation/usage/webcams/ has the instruction how to install. I think I don't know how to switch to webcam-capture-driver-fswebcam. The way I'm using library is by adding them to .sh file and I run .sh file to run program. since there is no jar file for this I have nothing to add and not sure what to do, can you please tell me little more specifically.

And do I need to remove installed driver (don't know how to remove), like I have installed vlc before.

I have tried with process builder today, it's simple and works with PI camera module.

sarxos commented 9 years ago

@aaav19983008, the ps didn't show any java process running. Instead you killed your terminal :)

Ok, when you already have fswebcam please test if you can capture the image. In the terminal execute:

$ fswebcam test.jpg

Then, copy test.jpg on your PC and verify if everything is ok with this snapshoot. When everything is good, please follow to the webcam-capture-fswebcam-driver page where you can read more about how to use it:

https://github.com/sarxos/webcam-capture/tree/master/webcam-capture-drivers/driver-fswebcam

Unfortunately the download link on the above page points to the old version (the 0.3.10-RC7 instead of 0.3.10), but the newest stable one can be found in Maven Central Repository:

http://search.maven.org/#artifactdetails|com.github.sarxos|webcam-capture-driver-fswebcam|0.3.10|jar

aaav19983008 commented 9 years ago

@sarxos

:) I have tried already, the image quality was not good with fswebcam xxx.jpg command,

then with this fswebcam -r 1280x720 xxx.jpg command was little better

the with this fswebcam -r 1280x720 --no-banner xxx.jpg command was better than before

ok, I following the link, will be back. :)

aaav19983008 commented 9 years ago

@sarxos

I have tried fswebcam, with the provided code (I have tried with webcam-capture-0.3.10.jar and webcam-capture-0.3.10-RC7.jar, didn't make any difference), not surprised that I got error, here is the log

20:37:15.214 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver FsWebcamDriver
20:37:15.461 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
20:37:15.750 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
20:37:15.902 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam /dev/video1
20:37:16.241 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam /dev/video1
20:37:16.245 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Creating pipe: mkfifo /tmp/fswebcam-pipe-video1.mjpeg
20:37:16.320 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
20:37:16.334 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
20:37:16.360 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open /dev/video1
20:37:16.401 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Invoking command: /usr/bin/fswebcam --no-banner --no-shadow --no-title --no-subtitle --no-timestamp --no-info --no-underlay --no-overlay -d /dev/video1 -r 176x144 /tmp/fswebcam-pipe-video1.mjpeg -v
20:37:16.415 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
20:37:16.418 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
20:37:16.538 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Opening /dev/video1...
20:37:16.544 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Trying source module v4l2...
20:37:16.604 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Error opening device: /dev/video1
20:37:16.613 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR open: Operation not permitted
20:37:16.616 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Trying source module v4l1...
20:37:16.621 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Error opening device: /dev/video1
20:37:16.631 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR open: Operation not permitted
20:37:16.633 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Unable to find a source module that can read /dev/video1.
20:37:16.637 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR
20:37:25.945 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
20:37:25.948 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
sarxos commented 9 years ago

Seems like fswebcam can only read from /dev/video0. Isn't /dev/video1 your RasPi camera module? This would explain why it cannot be read neither v4l nor v4l2. Can you disconnect it?

This error is not the Webcam Capture API issue. Neither the fswebcam. It simply means that v4l module is unable to read from /dev/video1 device.

aaav19983008 commented 9 years ago

@sarxos

only the USB camera is attached to the Pi not the RasPi camera, I have disconnected that, and from the previous error I can see that /dev/video0 is the RasPi camera module not the /dev/video1, I'm saying that because this is the first time this /dev/video1 one is appearing.

I have unplugged the camera and plugged it again (I suppose you meant that by saying "Can you disconnect it?"), but didn't make any difference.

As a result what can I do to make v4l module read form /dev/video1 device?

sarxos commented 9 years ago

@aaav19983008,

In regards to your question:

what can I do to make v4l module read form /dev/video1 device?

You can do nothing I guess. This device is not compatible with V4L. Some magic tricks with UV4L could possibly help, but I'm not familiar with this framework and cannot advice here.

One of these cameras is USB and when you ran fswebcam test.jpg it choose correct one (I suppose it was /dev/video0 because we verified that you cannot read from /dev/video1. I have no idea why your system is showing two cameras instead of just one, but I guess this is due to some kind of permanent configuration for RsPi camera module.

On, back to the topic, you have two cameras in your system, one can be read, and second cannot. You can try this to find out which one is ok:

System.out.println(Webcam.getWebcams().size()); // this should give you 2

Lets try first one:

Webcam w = Webcam.getWebcams().get(0);
w.open();
ImageIO.write(w.getImage(), "JPG", new File("0.jpg"));
w.close();

And second one:

Webcam w = Webcam.getWebcams().get(1);
w.open();
ImageIO.write(w.getImage(), "JPG", new File("1.jpg"));
w.close();

By doing this you should be able to determine which one is readable.

sarxos commented 9 years ago

PS. Just bought RasPi NoIR camera module. I will be experimenting with it in the next week.

aaav19983008 commented 9 years ago

@sarxos

I was little busy with something else for few days, sorry about that

By executing this line of code System.out.println(Webcam.getWebcams().size())

I found this

21:22:52.388 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
21:22:52.548 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
21:22:56.738 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Found device HP Webcam HD 2300 /dev/video0
1

By executing these line of code

             Webcam w = Webcam.getWebcams().get(0);
             w.open();
             ImageIO.write(w.getImage(), "JPG", new File("0.jpg"));
             w.close(); 

I found this

21:45:48.070 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
21:45:48.253 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:603)
        at java.util.ArrayList.get(ArrayList.java:381)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1225)
        at FinchTest.main(FinchTest.java:22)

By executing these line of code

             Webcam w = Webcam.getWebcams().get(1);
             w.open();
             ImageIO.write(w.getImage(), "JPG", new File("1.jpg"));
             w.close();

I found this

21:47:44.098 [main] INFO  com.github.sarxos.webcam.Webcam - WebcamDefaultDriver capture driver will be used
21:47:44.258 [webcam-discovery-service] DEBUG c.g.s.w.d.b.WebcamDefaultDriver - Searching devices
warning: error opening device
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:603)
        at java.util.ArrayList.get(ArrayList.java:381)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1225)
        at FinchTest.main(FinchTest.java:22)
sarxos commented 9 years ago

Hi @aaav19983008,

To be honest I have no idea what is happening on your RasPi...

  1. On Friday there was 2 webcams (/dev/video0 and dev/video1).
  2. On the first run today you had 1 webcam (/dev/video0).
  3. On the second run today you was not able to open device...
  4. On the third run today you was not able to open device again...

It looks like the camera is open already when you are trying to open it in 2. and 3.

Are you using fswebcam-driver or none (from the logs I see you are using none i.e. the default one)?

sarxos commented 9 years ago

Above you said you are using some shell script to run application, can you post it here?

aaav19983008 commented 9 years ago

@sarxos

to run program I run 2 .sh file, here is the first one build.sh (this version is just for finch {to make finch move} )

#!/bin/sh
LIBS=/home/pi/dev/BBTechSoftwareForPi/FinchJava
javac -classpath .:$LIBS/finch.jar FinchTest.java

-----------this one I used for camera, you will see name of the libraries

build.sh

#!/bin/sh
LIBS=/home/pi/dev/BBTechSoftwareForPi/FinchJava
javac -classpath .:$LIBS/slf4j-api-1.7.10.jar:xuggle-xuggler-5.4.jar:log4j-1.2.17.jar:logback-classic-1.1.2.jar:logback-core-1.1.2.jar:slf4j-api-1.7.2.jar:core-image-1.3.jar:webcam-capture-0.3.11-20141227.105512-4.jar:webcam-capture-driver-ipcam-0.3.10-RC7.jar:bridj-0.6.3-20130316.190111-13.jar FinchTest.java

other one run.sh

#!/bin/sh
LIBS=/home/pi/dev/BBTechSoftwareForPi/FinchJava
java -classpath .:$LIBS/finch.jar FinchTest

I have run those code one more time with both camera plugged in here are the results (I was feeling so excited when I saw that both of the camera is working) :) :)

for code System.out.println(Webcam.getWebcams().size())

here is the log

00:35:08.052 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver FsWebcamDriver
00:35:08.306 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
00:35:08.469 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
2

for code

Webcam w = Webcam.getWebcams().get(0);
             w.open();
             ImageIO.write(w.getImage(), "JPG", new File("0.jpg"));
             w.close();

here is log

00:36:04.989 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver FsWebcamDriver
00:36:05.240 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
00:36:05.402 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
00:36:05.536 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam /dev/video1
00:36:05.856 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam /dev/video1
00:36:05.860 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Creating pipe: mkfifo /tmp/fswebcam-pipe-video1.mjpeg
00:36:05.917 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:36:05.938 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:36:05.962 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open /dev/video1
00:36:06.004 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Invoking command: /usr/bin/fswebcam --no-banner --no-shadow --no-title --no-subtitle --no-timestamp --no-info --no-underlay --no-overlay -d /dev/video1 -r 176x144 /tmp/fswebcam-pipe-video1.mjpeg -v
00:36:06.012 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:36:06.069 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:36:06.093 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Opening /dev/video1...
00:36:06.100 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Trying source module v4l2...
00:36:06.343 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR /dev/video1 opened.
00:36:06.355 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,87: /dev/video1 information:
00:36:06.369 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,88: cap.driver: "raspicam"
00:36:06.377 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,89: cap.card: "Camera Board OV5647"
00:36:06.382 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,90: cap.bus_info: "CSI"
00:36:06.386 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,91: cap.capabilities=0x05000001
00:36:06.390 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,92: - VIDEO_CAPTURE
00:36:06.394 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,101: - READWRITE
00:36:06.397 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,103: - STREAMING
00:36:06.401 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR No input was specified, using the first.
00:36:06.403 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,181: /dev/video1: Input 0 information:
00:36:06.408 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,182: name = "default"
00:36:06.412 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,183: type = 00000002
00:36:06.420 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,185: - CAMERA
00:36:06.424 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,186: audioset = 00000000
00:36:06.427 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,187: tuner = 00000000
00:36:06.431 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,188: status = 00000000
00:36:06.435 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
00:36:06.438 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 0: [0x47504A4D] 'MJPG' (MJPEG Video)
00:36:06.441 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 1: [0x4745504A] 'JPEG' (JPEG Still)
00:36:06.445 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 2: [0x34363248] 'H264' (H264)
00:36:06.459 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 3: [0x32315559] 'YU12' (YUV 4:2:0)
00:36:06.462 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 4: [0x3132564E] 'NV21' (Y/CrCb 4:2:0)
00:36:06.465 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 5: [0x32315659] 'YV12' (YVU 4:2:0)
00:36:06.469 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 6: [0x50424752] 'RGBP' (RGB565)
00:36:06.472 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 7: [0x52424752] 'RGBR' (RGB565X)
00:36:06.477 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 8: [0x33424752] 'RGB3' (RGB24 LE)
00:36:06.480 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 9: [0x33524742] 'BGR3' (BGR24 BE)
00:36:06.484 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 10: [0x34424752] 'RGB4' (RGBA)
00:36:06.487 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 11: [0x34524742] 'BGR4' (BGRA)
00:36:06.490 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Using palette JPEG
00:36:06.694 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,693: mmap information:
00:36:06.697 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,694: frames=4
00:36:06.704 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 0 length=25344
00:36:06.711 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 1 length=25344
00:36:06.718 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 2 length=25344
00:36:06.726 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 3 length=25344
00:36:06.731 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Capturing frame...
00:36:07.055 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Captured frame in 0.00 seconds.
00:36:07.218 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Processing captured image...
00:36:07.242 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling banner.
00:36:07.248 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling text shadow.
00:36:07.251 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing title.
00:36:07.256 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing subtitle.
00:36:07.261 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing timestamp.
00:36:07.266 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing info text.
00:36:07.271 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing underlay.
00:36:07.276 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing overlay image.
00:36:07.298 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Writing JPEG image to '/tmp/fswebcam-pipe-video1.mjpeg'.
00:36:07.344 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR
00:36:08.220 [main] DEBUG com.github.sarxos.webcam.Webcam - Closing webcam /dev/video1
00:36:08.230 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamCloseTask - Closing /dev/video1
00:36:08.235 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Unlock Webcam /dev/video1
00:36:08.240 [webcam-lock-[/dev/video1]] DEBUG com.github.sarxos.webcam.WebcamLock - Lock updater has been interrupted
00:36:08.253 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam /dev/video1 has been closed

for code

Webcam w = Webcam.getWebcams().get(1);
             w.open();
             ImageIO.write(w.getImage(), "JPG", new File("1.jpg"));
             w.close();

here is the log

00:37:51.710 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver FsWebcamDriver
00:37:51.962 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
00:37:52.128 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
00:37:52.267 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam /dev/video0
00:37:52.582 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam /dev/video0
00:37:52.586 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Creating pipe: mkfifo /tmp/fswebcam-pipe-video0.mjpeg
00:37:52.648 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:37:52.664 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:37:52.689 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open /dev/video0
00:37:52.729 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Invoking command: /usr/bin/fswebcam --no-banner --no-shadow --no-title --no-subtitle --no-timestamp --no-info --no-underlay --no-overlay -d /dev/video0 -r 176x144 /tmp/fswebcam-pipe-video0.mjpeg -v
00:37:52.737 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:37:52.801 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:37:52.818 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Opening /dev/video0...
00:37:52.825 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Trying source module v4l2...
00:37:52.842 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR /dev/video0 opened.
00:37:52.857 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,87: /dev/video0 information:
00:37:52.865 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,88: cap.driver: "uvc"
00:37:52.869 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,89: cap.card: "HP Webcam HD 2300"
00:37:52.874 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,90: cap.bus_info: "usb-1-4"
00:37:52.879 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,91: cap.capabilities=0x05000001
00:37:52.883 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,92: - VIDEO_CAPTURE
00:37:52.886 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,101: - READWRITE
00:37:52.899 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,103: - STREAMING
00:37:52.902 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR No input was specified, using the first.
00:37:53.114 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,181: /dev/video0: Input 0 information:
00:37:53.120 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,182: name = "Camera"
00:37:53.123 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,183: type = 00000002
00:37:53.137 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,185: - CAMERA
00:37:53.214 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,186: audioset = 00000000
00:37:53.224 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,187: tuner = 00000000
00:37:53.231 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,188: status = 00000000
00:37:53.326 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
00:37:53.330 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 0: [0x56595559] 'YUYV' (YUV 4:2:2 (YUYV))
00:37:53.332 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 1: [0x47504A4D] 'MJPG' (MJPEG)
00:37:53.337 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Using palette MJPEG
00:37:53.342 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,693: mmap information:
00:37:53.349 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,694: frames=4
00:37:53.362 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 0 length=50688
00:37:53.374 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 1 length=50688
00:37:53.379 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 2 length=50688
00:37:53.390 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 3 length=50688
00:37:53.401 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Capturing frame...
00:37:54.065 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Captured frame in 0.00 seconds.
00:37:54.131 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Processing captured image...
00:37:54.133 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling banner.
00:37:54.134 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling text shadow.
00:37:54.136 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing title.
00:37:54.139 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing subtitle.
00:37:54.140 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing timestamp.
00:37:54.185 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing info text.
00:37:54.186 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing underlay.
00:37:54.189 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing overlay image.
00:37:54.190 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Writing JPEG image to '/tmp/fswebcam-pipe-video0.mjpeg'.
00:37:54.335 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR
00:37:55.634 [main] DEBUG com.github.sarxos.webcam.Webcam - Closing webcam /dev/video0
00:37:55.652 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamCloseTask - Closing /dev/video0
00:37:55.657 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Unlock Webcam /dev/video0
00:37:55.661 [webcam-lock-[/dev/video0]] DEBUG com.github.sarxos.webcam.WebcamLock - Lock updater has been interrupted
00:37:55.675 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam /dev/video0 has been closed

Here is some other interesting thing, when both camera plugged in at the same time and I run the program, only PI camera module took a photo, :) I have used these libraries

slf4j-api-1.7.10.jar:xuggle-xuggler-5.4.jar:log4j-1.2.17.jar:logback-classic-1.1.2.jar:logback-core-1.1.2.jar:slf4j-api-1.7.2.jar:core-image-1.3.jar: webcam-capture-0.3.10.jar:bridj-0.6.3-20130316.190111-13.jar:webcam-capture-driver-fswebcam-0.3.10.jar:webcam-capture-driver-fswebcam-0.3.10-RC7.jar: webcam-capture-0.3.10-RC7.jar

here is the code

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.ds.fswebcam.FsWebcamDriver;

public class camera {

    // set capture driver for fswebcam tool
    static {
        Webcam.setDriver(new FsWebcamDriver());
    }
        public static void main(String[] args) throws IOException{
        // get default webcam and open it
        Webcam webcam = Webcam.getDefault();
        webcam.open();

        // get image from webcam device
        BufferedImage image = webcam.getImage();

        // save image to PNG file
        ImageIO.write(image, "PNG", new File("test.png"));

        // close webcam
        webcam.close();

        }
}

here is the log

00:19:09.307 [main] DEBUG com.github.sarxos.webcam.Webcam - Setting new capture driver FsWebcamDriver
00:19:09.590 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video1
00:19:09.794 [webcam-discovery-service] INFO  c.g.s.w.ds.fswebcam.FsWebcamDriver - Found video file /dev/video0
00:19:09.938 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Lock Webcam /dev/video1
00:19:10.297 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamOpenTask - Opening webcam /dev/video1
00:19:10.301 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Creating pipe: mkfifo /tmp/fswebcam-pipe-video1.mjpeg
00:19:10.375 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:19:10.392 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:19:10.416 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam is now open /dev/video1
00:19:10.457 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - Invoking command: /usr/bin/fswebcam --no-banner --no-shadow --no-title --no-subtitle --no-timestamp --no-info --no-underlay --no-overlay -d /dev/video1 -r 176x144 /tmp/fswebcam-pipe-video1.mjpeg -v
00:19:10.472 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:19:10.529 [atomic-processor-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - New stream reader
00:19:10.606 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Opening /dev/video1...
00:19:10.610 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Trying source module v4l2...
00:19:11.036 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR /dev/video1 opened.
00:19:11.049 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,87: /dev/video1 information:
00:19:11.051 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,88: cap.driver: "raspicam"
00:19:11.056 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,89: cap.card: "Camera Board OV5647"
00:19:11.060 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,90: cap.bus_info: "CSI"
00:19:11.084 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,91: cap.capabilities=0x05000001
00:19:11.091 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,92: - VIDEO_CAPTURE
00:19:11.095 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,101: - READWRITE
00:19:11.106 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_get_capability,103: - STREAMING
00:19:11.109 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR No input was specified, using the first.
00:19:11.113 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,181: /dev/video1: Input 0 information:
00:19:11.116 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,182: name = "default"
00:19:11.120 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,183: type = 00000002
00:19:11.123 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,185: - CAMERA
00:19:11.126 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,186: audioset = 00000000
00:19:11.130 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,187: tuner = 00000000
00:19:11.133 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_input,188: status = 00000000
00:19:11.137 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,541: Device offers the following V4L2 pixel formats:
00:19:11.141 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 0: [0x47504A4D] 'MJPG' (MJPEG Video)
00:19:11.143 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 1: [0x4745504A] 'JPEG' (JPEG Still)
00:19:11.147 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 2: [0x34363248] 'H264' (H264)
00:19:11.151 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 3: [0x32315559] 'YU12' (YUV 4:2:0)
00:19:11.155 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 4: [0x3132564E] 'NV21' (Y/CrCb 4:2:0)
00:19:11.157 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 5: [0x32315659] 'YV12' (YVU 4:2:0)
00:19:11.161 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 6: [0x50424752] 'RGBP' (RGB565)
00:19:11.164 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 7: [0x52424752] 'RGBR' (RGB565X)
00:19:11.168 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 8: [0x33424752] 'RGB3' (RGB24 LE)
00:19:11.170 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 9: [0x33524742] 'BGR3' (BGR24 BE)
00:19:11.173 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 10: [0x34424752] 'RGB4' (RGBA)
00:19:11.181 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_pix_format,554: 11: [0x34524742] 'BGR4' (BGRA)
00:19:11.184 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Using palette JPEG
00:19:11.658 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,693: mmap information:
00:19:11.661 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,694: frames=4
00:19:11.668 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 0 length=25344
00:19:11.675 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 1 length=25344
00:19:11.683 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 2 length=25344
00:19:11.690 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR src_v4l2_set_mmap,741: 3 length=25344
00:19:11.692 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Capturing frame...
00:19:12.029 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Captured frame in 0.00 seconds.
00:19:12.188 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR --- Processing captured image...
00:19:12.207 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling banner.
00:19:12.212 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Disabling text shadow.
00:19:12.215 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing title.
00:19:12.220 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing subtitle.
00:19:12.225 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing timestamp.
00:19:12.238 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing info text.
00:19:12.245 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing underlay.
00:19:12.252 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Clearing overlay image.
00:19:12.268 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR Writing JPEG image to '/tmp/fswebcam-pipe-video1.mjpeg'.
00:19:12.319 [process-reader-1] DEBUG c.g.s.w.ds.fswebcam.FsWebcamDevice - FsWebcam: ERROR
00:19:13.670 [main] DEBUG com.github.sarxos.webcam.Webcam - Closing webcam /dev/video1
00:19:13.682 [atomic-processor-1] INFO  c.g.s.webcam.ds.cgt.WebcamCloseTask - Closing /dev/video1
00:19:13.687 [main] DEBUG com.github.sarxos.webcam.WebcamLock - Unlock Webcam /dev/video1
00:19:13.691 [webcam-lock-[/dev/video1]] DEBUG com.github.sarxos.webcam.WebcamLock - Lock updater has been interrupted
00:19:13.704 [main] DEBUG com.github.sarxos.webcam.Webcam - Webcam /dev/video1 has been closed

image size is around 40 kb, so the summary is both camera works.

sarxos commented 9 years ago

That is great! In this case I'm closing this ticket.

aaav19983008 commented 9 years ago

@sarxos Thank you so much for your support, guideline and time you have spent, really appreciate that. One additional question Since I have to do image processing after that, I'm struggling to find a helpful resource, I have less than a week to do that, if you know anything about it can you please just provide link or something you think appropriate.

sarxos commented 9 years ago

@aaav19983008,

You're welcome :)

In regards to your question - it really depends on what processing you need to to, but if you want to stick to the Java I would suggest to start with OpenIMAJ (which yesterday migrated from Sourceforge to Github):

http://www.openimaj.org/ https://github.com/openimaj/openimaj

This project consist of many dependencies so at least basic knowledge of Maven may be required in your case, but it's imho still a better option than using OpenCV, which may be much harder to learn. But do not use VideoCapture class since it most likely won't run on your RasPi (Webcam Capture API default driver use the same classes and we saw you get SIGSEGV).

If you think OpenIMAJ does not fit into your needs you can try BoofCV (I think it's a little bit simpler when working with images, but I have no idea about performance):

http://boofcv.org https://github.com/lessthanoptimal/BoofCV

Or use JavaCV wrapper for OpenCV (but I'm not sure if it will run on RasPi):

https://github.com/bytedeco/javacv