Skip to content

Instantly share code, notes, and snippets.

@drewrwilson
Forked from madhephaestus/camera.groovy
Last active August 29, 2015 14:27
Show Gist options
  • Save drewrwilson/a693f52508aa64ae0fa8 to your computer and use it in GitHub Desktop.
Save drewrwilson/a693f52508aa64ae0fa8 to your computer and use it in GitHub Desktop.
BowlerStudio Cameras
import java.awt.image.BufferedImage;
import com.neuronrobotics.jniloader.Detection;
import java.util.List;
println("HELLO DUUUUUUDE")
// Starting with the connected camera from BowlerStudio
println(camera0)
//Create the default detector using "lbpcascade_frontalface.xml"
IObjectDetector detector = new HaarDetector("lbpcascade_frontalface.xml")
// Create the input and display images. The display is where the detector writes its detections overlay on the input image
BufferedImage inputImage = AbstractImageProvider.newBufferImage(640,480)
BufferedImage displayImage = AbstractImageProvider.newBufferImage(640,480)
// Loop checking the camera for faces
while(!Thread.interrupted()){
camera0.getLatestImage(inputImage,displayImage) // capture image
List<Detection> data = detector.getObjects(inputImage, displayImage)
if(data.size()>0){
println("Got: "+data.size()+
" x location = "+data.get(0).getX()+
" y location "+data.get(0).getY()+
" size = "+data.get(0).getSize() )
int position = (data.get(0).getX()/320.0)*255;
dyio.setValue(0,position)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment