-
-
Save drewrwilson/a693f52508aa64ae0fa8 to your computer and use it in GitHub Desktop.
BowlerStudio Cameras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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