Skip to content

Commit

Permalink
Use vlcj direct rendering instead of snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Jan 22, 2015
1 parent b793d61 commit fac1e05
Show file tree
Hide file tree
Showing 9 changed files with 394 additions and 151 deletions.
26 changes: 13 additions & 13 deletions README.md
@@ -1,11 +1,11 @@
# Webcam Capture API for Java
# Webcam Capture API

This library allows you to use your build-in or external webcam directly from Java. It's designed to abstract commonly used camera features and support multiple capturing farmeworks.

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.sarxos/webcam-capture/badge.svg)](http://search.maven.org/#artifactdetails|com.github.sarxos|webcam-capture|0.3.10|bundle)
[![Build Status](https://img.shields.io/travis/sarxos/webcam-capture.svg?branch=master)](http://travis-ci.org/sarxos/webcam-capture)
[![Coverage Status](https://img.shields.io/coveralls/sarxos/webcam-capture.svg?branch=master)](https://coveralls.io/r/sarxos/webcam-capture?branch=master)
[![Ohloh Stats](https://img.shields.io/badge/ohloh-%24%20243k%2019.7%20kNCSL-blue.svg)](https://www.ohloh.net/p/java-webcam-capture)
[![Ohloh Stats](https://img.shields.io/badge/ohloh-19.7kNCSL-blue.svg)](https://www.ohloh.net/p/java-webcam-capture)

## Features

Expand All @@ -27,7 +27,7 @@ This library allows you to use your build-in or external webcam directly from Ja
* [Freedom for Media in Java (FMJ)](http://fmj-sf.net/),
* [OpenCV](http://opencv.org/) via [JavaCV](https://github.com/bytedeco/javacv),
* [VLC](http://www.videolan.org/vlc/) via [vlcj](http://www.capricasoftware.co.uk/projects/vlcj/index.html),
* [GStreamer](http://gstreamer.freedesktop.org/) via [gstreamer-java](https://code.google.com/p/gstreamer-java/)
* [GStreamer](http://gstreamer.freedesktop.org/) (0.10.x only) via [gstreamer-java](https://code.google.com/p/gstreamer-java/)
* MJPEG IP Cameras,

## Raspberry PI
Expand Down Expand Up @@ -150,15 +150,15 @@ List of additional capture drivers includes:

| Driver Name | Stable | Central | Description |
|-----------------|--------|---------|-----------------------------------------|
| [ipcam][] | yes | yes | IP / network camera driver |
| [gstreamer][] | yes | no | Driver for [GStreamer][] framework |
| [openimaj][] | yes | no | Driver for [OpenIMAJ][] framework |
| [v4l4j][] | yes | no | Driver for [V4L4j][] project |
| [jmf][] | yes | yes | Driver for [JMF][] / [FMJ][] frameworks |
| [lti-civil][] | yes | yes | Driver for [LTI-CIVIL][] library |
| [javacv][] | no | no | Driver for [JavaCV][] library |
| [vlcj][] | no | no | Driver for [VLCj][] library |
| [ffmpeg-cli][] | exp | no | Driver for [FFmpeg][] [CLI][] tool |
| [ipcam][] | yes | yes | Driver for IP / network camera |
| [gstreamer][] | yes | no | Driver for [GStreamer][] framework |
| [openimaj][] | yes | no | Driver for [OpenIMAJ][] framework |
| [v4l4j][] | yes | no | Driver for [V4L4j][] library |
| [jmf][] | yes | yes | Driver for [JMF][] / [FMJ][] frameworks |
| [lti-civil][] | yes | yes | Driver for [LTI-CIVIL][] library |
| [javacv][] | no | no | Driver for [JavaCV][] library |
| [vlcj][] | yes | yes | Driver for [vlcj][] library |
| [ffmpeg-cli][] | exp | no | Driver for [FFmpeg][] [CLI][] tool |

* Central = Maven Central Repository
* _exp_ = experimental
Expand Down Expand Up @@ -190,7 +190,7 @@ I initially started working on Webcam Capture as a simple proof-of-concept after

## License

Copyright (C) 2012 - 2015 Bartosz Firyn
Copyright (C) 2012 - 2015 Bartosz Firyn (https://github.com/sarxos)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
16 changes: 3 additions & 13 deletions webcam-capture-drivers/driver-vlcj/README.md
@@ -1,18 +1,8 @@
# webcam-capture-driver-vlcj

This is capture driver which uses [vlcj](http://www.capricasoftware.co.uk/projects/vlcj/index.html)
library from [Caprica Software Limited](http://www.capricasoftware.co.uk/)
to gain access to the camera device.
This is capture driver which uses [vlcj](http://www.capricasoftware.co.uk/projects/vlcj/index.html) library from [Caprica Software Limited](http://www.capricasoftware.co.uk/) to gain access to the camera device.

Because vlcj saves every frame to the persistent storage (temporary directory on your hard drive)
before it is returned by the API method call,
the image capture rate is pretty small, indicated by tests to be around ~12 FPS, but it can pe
possibly higher or lower depending on the hardware used (e.g. different on hard drive, SSD and
flash memory).

**NOTE!** On Windows one needs to provide list of webcam devices manually because
```vlclib``` does not implement video devices discovery on this platform (please see [this example](https://github.com/sarxos/webcam-capture/blob/master/webcam-capture-drivers/driver-vlcj/src/example/java/WebcamPanelForWindows.java)
to find out how this should be done).
**NOTE!** On Windows one needs to provide list of webcam devices manually because ```vlclib``` does not implement video devices discovery on this platform (please see [this example](https://github.com/sarxos/webcam-capture/blob/master/webcam-capture-drivers/driver-vlcj/src/example/java/WebcamPanelForWindows.java) to find out how this should be done).

The vlcj library is distributed according to the terms of the [GPL](http://www.gnu.org/licenses/gpl.html) license.

Expand All @@ -22,7 +12,7 @@ Not yet available.

## Capture Driver License

Copyright (C) 2012 - 2014 Bartosz Firyn <https://github.com/sarxos>
Copyright (C) 2012 - 2015 Bartosz Firyn <https://github.com/sarxos>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
5 changes: 5 additions & 0 deletions webcam-capture-drivers/driver-vlcj/pom.xml
Expand Up @@ -31,6 +31,11 @@
<artifactId>vlcj</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Expand Up @@ -75,6 +75,7 @@ private static BufferedImage convert(Memory[] buffers, BufferFormat format) {
ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ComponentSampleModel sampleModel = new ComponentSampleModel(dataType, width, height, pixelStride, scanlineStride, bgrBandOffsets);
ComponentColorModel colorModel = new ComponentColorModel(colorSpace, bits, false, false, transparency, dataType);

DataBufferByte dataBuffer = new DataBufferByte(data, bytes.length, offsets);
WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer, null);
BufferedImage image = new BufferedImage(colorModel, raster, false, null);
Expand Down Expand Up @@ -119,7 +120,6 @@ public void display(DirectMediaPlayer player, Memory[] buffers, BufferFormat for
":v4l2-width=320",
":v4l2-height=240",
":v4l2-fps=30",
":v4l2-quality=20",
":v4l2-adev=none",
};

Expand Down
Expand Up @@ -19,10 +19,10 @@ public static void main(String[] args) throws InterruptedException {

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

JFrame window = new JFrame("Webcam Panel");
window.add(panel);
window.setResizable(false);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
Expand Down

0 comments on commit fac1e05

Please sign in to comment.