3

Current I am developing a JavaFX application that should display video to the user. I use https://github.com/sarxos/webcam-capture to retreive video data. I use v4l4j to get video on the pi. I use https://github.com/sarxos/webcam-capture/issues/419. I use the official raspberry pi camera.

I use verion bridj-0.7-20140918.jar of v4l4j for video streaming. I use the following code to capture video:

public void startCamera()
{
    final Webcam webcam = currentWebcam.get();
    if (webcam != null && !webcam.isOpen())
    {
        webcam.open();

        cameraThread = new Thread(() ->
        {
            final AtomicReference<WritableImage> ref = new AtomicReference<>();
            BufferedImage img;
            while (true)
            {
                try
                {
                    if ((img = webcam.getImage()) != null)
                    {
                        ref.set(SwingFXUtils.toFXImage(img, ref.get()));
                        img.flush();

                        Platform.runLater(() -> currentFrame.set(ref.get()));
                    }
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
        });

        cameraThread.setDaemon(true);
        cameraThread.start();
    }
}

Where currentWebcam is a JavaFX ObjectProperty<Webcam>, and currentFrame is a ObjectProperty<Image>. And ImageView in the view listens to any changes to this object and updates the frame accordingly.

When starting the application I also get the following (non-application breaking) error:

[ libvideo.c:68 ] Using libvideo version 0.9-UNKNOWN
[ v4l2-query.c:49 ] Error looking up V4L2 format 34363248. Please submit
a bug report on the v4l4j mailing list.[ v4l2-query.c:484 ] libvideo has skipped an unsupported image format:
[ v4l2-query.c:485 ] H.264 (0x34363248)
[ v4l2-query.c:486 ] Please let the author know about this error.
[ v4l2-query.c:487 ] See the ISSUES section in the libvideo README file.

When running a pi script that uses picamera the quality is noticably better. It there a reason why the quality is so poor here? Latency does not seem to be an issue here strangely.

As a sidenote, the image is also square. I would like for it to be widescreen without having to blow-up the screen.

I there perhaps another driver/solution I could look at? One with high-throughput. I'd only want to switch to python as a last resort.

  • 1
    It might be worth putting your recorded video files through something like avprobe to nail down exactly what the differences are between your program and picamera. – goobering May 23 '17 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.