-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot identify '▒y▒Xp ▒▒ ▒(▒▒': 2, No such file or directory #314
Comments
@aaav19983008 when you try to run the above code, is your webcam running using another application ? |
Hi @aaav19983008, I suppose this error:
Comes from: However, the root cause, i.e. why is device name I'm trying to find out if gstreamer or vlc can be used instead. |
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.
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);
}
} |
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. :) |
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? |
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 Things are different for USB cameras. Those should work in 99% cases. In regards to your question. The camera name cannot be changed. The |
@sarxos |
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 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 There is no plain Java API that will act like a nice proxy to |
@sarxos 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
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
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
-----------------------------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
Can you please give me some idea, I'm desperate to make it work. |
Today after I'm back at home I will commit changes in 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
This is strange:
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 |
I don't really remember why I was releasing the lock! But still, even without releasing the lock the problem is same,
by using this command "ps -ef | grep -i java" what I found is
and if I execute "kill -9 2635", it shuts down Putty immediately. I have Installed fswebcam, this link 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. |
@aaav19983008, the Ok, when you already have
Then, copy Unfortunately the download link on the above page points to the old version (the http://search.maven.org/#artifactdetails|com.github.sarxos|webcam-capture-driver-fswebcam|0.3.10|jar |
:) 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. :) |
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
|
Seems like fswebcam can only read from This error is not the Webcam Capture API issue. Neither the |
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? |
In regards to your question:
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 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. |
PS. Just bought RasPi NoIR camera module. I will be experimenting with it in the next week. |
I was little busy with something else for few days, sorry about that By executing this line of code I found this
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
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
|
Hi @aaav19983008, To be honest I have no idea what is happening on your RasPi...
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)? |
Above you said you are using some shell script to run application, can you post it here? |
to run program I run 2 .sh file,
-----------this one I used for camera, you will see name of the libraries build.sh
other one run.sh
I have run those code one more time with both camera plugged in for code here is the log
for code
here is log
for code
here is the log
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, :) 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: 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
image size is around 40 kb, so the summary is both camera works. |
That is great! In this case I'm closing this ticket. |
@sarxos |
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/ 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 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 Or use JavaCV wrapper for OpenCV (but I'm not sure if it will run on RasPi): |
Hi, I'm trying to capture an image from Raspberry PI, using this code in java
I'm using these libraries
the operating system I'm using
this is the error log
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.
The text was updated successfully, but these errors were encountered: