Skip to content

Webcam not reporting a captured frame? #32

Closed

Description

@Bazmundi

I have an old bloggie duo use as a webcam to work on the use of the unwrapped 360 degree lens as a visual collision detector for my robotics experiments (http://www.keepad.com/products/sony/Cameras/Bloggie/MHSFS2KP/).

Now the camera comes up in my windows driver list as a webcam. I have used the free webcam software MyCam to view the Bloggie working as a webcam.

If I use the example code from Processing site for Capture (https://processing.org/reference/libraries/video/Capture.html)

The bloggie turns up in the Available list of cameras. Although, confusingly it turns up as a number of cameras of alternate resolutions. No matter, Capture appears to "see" the bloggie.

However, the cam.available() never returns true suggesting a video frame is never available.

I have tried using various index values into cameras to, pick up alternate instances of the bloggie resolution instances, no no avail. I have tried hard coding resolutions, frame rates, camera names etc. to no avail.

MyCam reports the bloggie at a specific resolution and framerate so assuming that is the default I have made a special point of setting those parameters, to no avail.

Regardless, cam.available() never returns true.

I wrapped the capture calls in try blocks and no exceptions appear to get raised.

If I print the cam pointer it comes up with: processing.video.Capture@2d5e7ba3
So, the Capture instance appears to have been created.

So, there is no exception or other means to "explain" why the camera can be "seen" by Capture.list() but fails to return a frame.

Any ideas please?

Running on windows 7.

Cheers,
A

Activity

  1. Bazmundi commented on Aug 4, 2015

    @Bazmundi
    Author

    Ah, if I shut the window an exception is raised:

    (java.exe:7388): GStreamer-CRITICAL **: 
    Trying to dispose element Video Capture, but it is in READY instead of the NULL state.
    You need to explicitly set elements to the NULL state before
    dropping the final reference, to allow them to clean up.
    This problem may also be caused by a refcounting bug in the
    application or some element.
    

    Other people appear to have sorted by installing gstreamer. Interesting neither the Capture nor Video pages actually tell you that you might need to install a separate driver package.

    Upshot, however, is installing gstreamer from gstreamer site does not fix the problem with the display not drawing (capture event not happenning?), however, it appears to have fixed the problem with the exception being raised when one closes the window.

  2. Bazmundi commented on Aug 8, 2015

    @Bazmundi
    Author

    So I have verified the camera is fine when using another Java based library (https://github.com/sarxos/webcam-capture). I will play with using that library in Processing instead.

  3. txeni commented on Aug 19, 2015

    @txeni

    Hi there,

    I'm having the same problem with a Lenovo Yoga and with a Dell windows tablet.
    Tried a lot of Processing versions 2.0.3, 2.2.1, and all the 3 betas.
    As you I get available cameras, but seems not capture event happening.
    Funny thing if I connect a usb camera to any of the devices that camera works...

    Did you solve it?
    Are you using that other library?
    If so, could you post a little example, I don't really know how to start with it...

    Thanks!

  4. Bazmundi commented on Aug 20, 2015

    @Bazmundi
    Author

    @txeni yes. I will post something this weekend. Stay tuned.

  5. txeni commented on Aug 20, 2015

    @txeni

    @Bazmundi thanks soooo much!
    Please, please, please do as soon as you can, it's driving me crazy and I'm in deep deadline shit!

  6. Bazmundi commented on Aug 22, 2015

    @Bazmundi
    Author
  7. txeni commented on Aug 22, 2015

    @txeni

    Thank you so much!!!
    I'll have a look :)

  8. txeni commented on Aug 22, 2015

    @txeni

    Got the mini-screen working!
    I'll keep at it to see if I can actually get the frames, basically that's what i need from the camera each individual frame to play with it.
    I should be able to find a way to get them and then transform them to PImage, looking at the library examples right now.
    Thank you soooooo much!

  9. Bazmundi commented on Aug 22, 2015

    @Bazmundi
    Author

    @txeni I only poked around on the Internet, thank Bartosz Firyn who wrote the library ;) Good luck with your deadline.

  10. txeni commented on Aug 23, 2015

    @txeni

    In case anyone else is going this route this is how I converted BufferedImage to PImage:

    BufferedImage cap = webcam.getImage();
    PImage screen = new PImage(cap.getWidth(),cap.getHeight(),PConstants.ARGB);
    cap.getRGB(0, 0, screen.width, screen.height, screen.pixels, 0, screen.width);
    screen.updatePixels();

  11. txeni commented on Aug 23, 2015

    @txeni

    And this is how I imitated the camera example using this library:

    import com.github.sarxos.webcam.Webcam;
    import com.github.sarxos.webcam.WebcamPanel;
    import com.github.sarxos.webcam.WebcamResolution;
    import java.awt.Dimension;
    import java.awt.Image;
    import java.awt.image.BufferedImage;

    Webcam webcam;

    void setup()
    {
    size(displayWidth, displayHeight);
    imageMode(CENTER);

    for (Webcam camlist : Webcam.getWebcams ()) {
    println(camlist.getName());
    for (Dimension res : camlist.getViewSizes()) println(res.toString());
    }

    webcam = Webcam.getDefault();
    //webcam = Webcam.getWebcamByName("iLook 300 0");

    webcam.setViewSize(WebcamResolution.VGA.getSize());
    webcam.open(true);
    }
    void draw()
    {
    BufferedImage cap = webcam.getImage();
    PImage screen = new PImage(cap.getWidth(),cap.getHeight(),PConstants.ARGB);
    cap.getRGB(0, 0, screen.width, screen.height, screen.pixels, 0, screen.width);
    screen.updatePixels();

    image(screen, width/2, height/2);
    }

  12. Bazmundi commented on Aug 23, 2015

    @Bazmundi
    Author

    @txeni Good job! If you need any image processing BoofCV is looking very good. Infact, it turns out in the Java examples they actually use the sarxos webcam-capture library 0.3.10 so there are examples of how to get the camera image into BoofCV shenanigans.

  13. codeanticode commented on Sep 4, 2015

    @codeanticode
    Contributor

    hey guys, I just saw this thread. The webcam-capture library looks really amazing, and I'm happy to know it solves the capture issues for people. I wonder if it would make sense to internally replace gstreamer for the Capture class and use webcam-capture instead.

  14. txeni commented on Sep 4, 2015

    @txeni

    Hey, the library works fine for a lot of cameras, but some of them don't go over 640x480, i think because they use h264 compression after that, but i'm not sure, just my theory after reading this by the creator of the library:

    "most of these fancy cameras with UHD resolutions comes with the dedicated software that integrates with Windows and works on top of the h.264 that is natively supported by webcam, but Java API is not able to use it (usually RGB24 format is used, or YUV, no h.264 support)." sarsox here: sarxos/webcam-capture#380

    Getting newer versions of gstreamer to work with processing's video library would be amazing...

  15. jeffmarc10 commented on Sep 3, 2017

    @jeffmarc10

    So I am here from searching for solution to my camera issues with Processing.
    Having similar problems , camera in list but not capturing, using 640x480 , still no luck
    Did this integration ever happen in newer version of Processing? or is it still the same ?
    Has there been any update of the video library in Processing to solve these issues?
    I have tryed 4 cameras, the ones that show up as Image devices in Device manager and are UVC work up to 5MP no problem!
    But other cameras that install under Sound, Video and Game controllers in Device Manager do not.
    I also have a Sentech 5MP camera that uses USB3.0Vision, it installs under Sentech in Device manager and does not show up in camera list at all.
    Is there any other library that would integrate with Processing for USB3 Vision support?
    Thanks!

  16. codeanticode commented on Aug 25, 2019

    @codeanticode
    Contributor

    @jeffmarc10 @txeni @Bazmundi Returning to this old issue, in case it is still relevant, the latest beta of the video library uses GStreamer 1.x so it might have better support for capture devices. It also has some preliminary support for custom pipelines, which could help with more specialized capture hardware, as discussed here. The beta is not available through the Contributions Manager, so you have to install it manually, but the upcoming stable v2.0 release will be.

  17. codeanticode commented on Jan 16, 2023

    @codeanticode
    Contributor

    No updates on this issue, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions