1

I'm looking to take images using my raspberry pi v2 camera module and extract a specific part of those using ROI.

-roi 0.5,0.5,0.25,0.25  

However, ROI seems to only be a flag for taking still images through the command line, is there any way to use ROI with the 'camera' module in code?.

such as...

camera.resolution = (2592, 1944)
camera.framerate = 15
#does this next line exist somewhere?
camera.roi = (0.5,0.5,0.25,0.25)

Any help would be much appreciated!

yupthatsme
  • 47
  • 7
  • Grab the whole frame then extract the ROI with Numpy slicing, e.g. `ROI=fullframe[100:200, 500:800]` – Mark Setchell Feb 15 '20 at 21:51
  • Hey Mark thanks for the answer, I think that would have worked too, but I found a PIL Library function that worked just as well – yupthatsme Feb 16 '20 at 01:18

2 Answers2

0

I found the PIL Library has a function .crop() that did exactly what I needed. Link here PIL Link

yupthatsme
  • 47
  • 7
0

Yes it is a property called 'zoom'. (in your example, camera.zoom)

zoom Retrieves or sets the zoom applied to the camera’s input.

When queried, the zoom property returns a (x, y, w, h) tuple of floating point values ranging from 0.0 to 1.0, indicating the proportion of the image to include in the output (this is also known as the “Region of Interest” or ROI). The default value is (0.0, 0.0, 1.0, 1.0) which indicates that everything should be included. The property can be set while recordings or previews are in progress.

More info here: https://picamera.readthedocs.io/en/release-1.10/api_camera.html