Skip to content

Commit

Permalink
Add default build in driver
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Jul 19, 2012
1 parent 6928163 commit 49e53cd
Show file tree
Hide file tree
Showing 20 changed files with 937 additions and 28 deletions.
2 changes: 1 addition & 1 deletion webcam-capture-driver-openimaj/pom.xml
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>org.openimaj</groupId>
<artifactId>core-video-capture</artifactId>
<version>1.0.5</version>
<version>1.0.6-x</version>
</dependency>
</dependencies>

Expand Down
Expand Up @@ -4,12 +4,11 @@
import java.awt.image.BufferedImage;

import org.openimaj.image.ImageUtilities;
import org.openimaj.video.capture.Device;
import org.openimaj.video.capture.VideoCapture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.sarxos.webcam.WebcamDevice;
import com.github.sarxos.webcam.ds.buildin.natives.Device;


public class OpenImajDevice implements WebcamDevice {
Expand All @@ -20,7 +19,7 @@ public class OpenImajDevice implements WebcamDevice {
* Artificial view sizes. I'm really not sure if will fit into other webcams
* but hope that OpenIMAJ can handle this.
*/
private final static Dimension[] dimensions = new Dimension[] {
private final static Dimension[] DIMENSIONS = new Dimension[] {
new Dimension(176, 144),
new Dimension(320, 240),
new Dimension(352, 288),
Expand All @@ -45,7 +44,7 @@ public String getName() {

@Override
public Dimension[] getSizes() {
return dimensions;
return DIMENSIONS;
}

@Override
Expand Down
@@ -1,22 +1,24 @@
package com.github.sarxos.webcam.ds.openimaj;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;

import org.openimaj.video.capture.Device;
import org.openimaj.video.capture.VideoCapture;

import com.github.sarxos.webcam.WebcamDriver;
import com.github.sarxos.webcam.WebcamDevice;
import com.github.sarxos.webcam.WebcamDriver;
import com.github.sarxos.webcam.ds.buildin.natives.Device;


/**
* This is webcam driver for OpenIMAJ library.
*
* @author Bartosz Firyn (SarXos)
*/
public class OpenImajDriver implements WebcamDriver {

List<WebcamDevice> webcamDevices = null;
/**
* Cached webcams list.
*/
private static List<WebcamDevice> webcamDevices = null;

@Override
public List<WebcamDevice> getDevices() {
Expand All @@ -32,15 +34,4 @@ public List<WebcamDevice> getDevices() {
return webcamDevices;
}

public static void main(String[] args) throws IOException, InterruptedException {
WebcamDevice d = new OpenImajDriver().getDevices().get(0);
d.setSize(d.getSizes()[0]);
d.open();
for (int i = 0; i < 5; i++) {
ImageIO.write(d.getImage(), "JPG", new File(System.currentTimeMillis() + ".jpg"));
Thread.sleep(1000);
}

d.close();
}
}

0 comments on commit 49e53cd

Please sign in to comment.