Skip to content

Commit

Permalink
Not able to detect camera, hot fix for #35
Browse files Browse the repository at this point in the history
fixes #35
  • Loading branch information
sarxos committed Feb 8, 2013
1 parent 7fa3b8c commit fc7dd94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
@@ -0,0 +1,13 @@
package com.github.sarxos.webcam;

public class DetectWebcamExample {

public static void main(String[] args) {
Webcam webcam = Webcam.getDefault();
if (webcam != null) {
System.out.println("Webcam: " + webcam.getName());
} else {
System.out.println("No webcam detected");
}
}
}
2 changes: 1 addition & 1 deletion webcam-capture/src/example/resources/logback.xml
Expand Up @@ -4,7 +4,7 @@
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<root level="warn">
<root level="trace">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Expand Up @@ -29,18 +29,19 @@ public class WebcamDefaultDriver implements WebcamDriver, WebcamDiscoverySupport
*/
private static final Logger LOG = LoggerFactory.getLogger(WebcamDefaultDriver.class);

/**
* Native grabber.
*/
private static final OpenIMAJGrabber GRABBER = new OpenIMAJGrabber();
private static OpenIMAJGrabber grabber = null;

@Override
public List<WebcamDevice> getDevices() {

LOG.debug("Searching devices");

if (grabber == null) {
grabber = new OpenIMAJGrabber();
}

List<WebcamDevice> devices = new ArrayList<WebcamDevice>();
Pointer<DeviceList> pointer = GRABBER.getVideoDevices();
Pointer<DeviceList> pointer = grabber.getVideoDevices();
DeviceList list = pointer.get();

for (Device device : list.asArrayList()) {
Expand Down

0 comments on commit fc7dd94

Please sign in to comment.