-
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
Black image captured instead of view from camera #285
Comments
It would be more helpful if you post more details, such as:
|
this is the source code: Webcam.setAutoOpenMode(true);
Webcam webcam = Webcam.getDefault();
BufferedImage im = webcam.getImage();
ImageIO.write(im, "PNG", new File("D:\\test.png"));
webcam.close(); the version im using is 0.3.10 |
That's weird, however I never expect anything else from Windows :) I suppose that this may be caused by the fact that camera buffer is empty at the very beginning. The Webcam Capture API automatically discard the first three frames that comes from the grabber (the buffer memory). This is happening in WebcamDefaultDevice.java line 360. I empirically verified that the camera buffer size is 5, but in all my experiments only the first frame was blank, so it's very weird why you're getting empty image (the 4'th frame from buffer). This is in regards to the root cause, but later today I will provide you with the source code I would like you to execute to verify what is the number of first non-blank image you receive from camera. By knowing this we can fine-tune the number of frames that must be discarded and I can hopefully do small modification in the code to fix your problem. |
i got it thanks the first 2 images are blank but the 3rd image is fine. thanks a lot |
Ok, so it seems like all the 5 elements of initial camera buffer were empty. I will introduce the fix to discard all of them before the camera device is open. |
Is it possible to stream the live video feed onto any another device such as a smart phone through socket programing? |
Yes, this is possible. There is a video streaming proof-of-concent example that demonstrates how to transcode |
thanks i will look into it. |
I'm opening this ticket so I remember to fix that. |
I implemented the change we were talking about. It should work fine now and all of the initial memory buffer elements should be removed so the black image should not appear any more. It is available in 0.3.11-SNAPSHOT. Just FYI if you want to take a look, the @ryancheu fork of webcam-capture-live-streaming example is adding supports for additional audio streaming (source code at webcam-capture-live-streaming @ ryancheu). |
Hey iam using windows 10 64 bit ,i have two webcam 1.) inbuild laptop webcam 2.) usb webcam.
Using javafx and java 8 (IDE netbeans 8.2). |
hey, i am using windows 64 bit and i am trying a simple capture image code but the it unable to capture an image. the captured image is attached

The text was updated successfully, but these errors were encountered: