-
Notifications
You must be signed in to change notification settings - Fork 27
Taking a Picture
Andrew Dillon edited this page Nov 24, 2016
·
4 revisions
The most basic way to take an image with JRPiCam is to invoke the takeStill()
method:
RPiCamera piCamera = new RPiCamera();
piCamera.takeStill("My First JRPiCam Image.jpg); //Take and save an image
The above code creates an instance of RPiCamera
and uses it to call the takeStill()
method. takeStill()
captures an image and then saves it to the RPiCamera
's save directory (which in this case is "/home/pi/Pictures" since we didn't specify anything different, see this page for for detail). The result of this code will be a JPEG image located at "/home/pi/Pictures/My First JRPiCam Image.jpg".
The dimensions of an image can also be specified in takeStill()
:
piCamera.takeStill("ACoolImage.jpg", 500, 500); //takes a 500x500 image
takeStill()
also returns a File
representing the image that was taken and saved. One way this feature can be taken advantage of is to load the saved image into a BufferedImage
:
BufferedImage myPic = ImageIO.read(piCamera.takeStill("ACoolImage.jpg", 500, 500)); //takes and saves an image, then loads it into a BufferedImage from the Pi's memory