jcozar87
Posts: 5
Joined: Sat Apr 29, 2017 6:02 pm

raspistill --roi unexpected behaviour

Sat Apr 14, 2018 3:01 pm

As far as I understood from the documentation, zoom is composed of (x, y, w, h)

Let's say we have an image of w, h = (3280, 2464). If I use a zoom = (0.25, 0.25, 0.5, 0.5) I expect to capture images where the center part matches with the center of the full image (like a x2 zoom). And the result is correct.

Code: Select all

raspistill -w 1640 -h 1232 --roi "0.25, 0.25, 0.5, 0.5" -o 'image.jpg'
However, If I want the right part of the image (of resolution w, h = (1640, 2464)), I expect that using a zoom=(0.5, 0, 0.5, 0.5) gives me that part of the image. However, the following instruction modify the aspect ratio of the image and gives me an unexpected part of the image. What am I missing here?

Code: Select all

raspistill -w 1640 -h 2464 --roi "0.5, 0, 0.5, 1" -o 'image.jpg'


User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: raspistill --roi unexpected behaviour

Sat Apr 14, 2018 6:06 pm

jcozar87 wrote:
Sat Apr 14, 2018 3:01 pm
the following instruction modify the aspect ratio of the image and gives me an unexpected part of the image.
i see the expected part of the image but wrong ratio...
anyhow i only understand when i see all:
nano RPIcamsnap_roi.sh

Code: Select all

#!/bin/bash
# test roi / zoom
TODAY=$(date +'%Y-%m-%d_%H:%M:%S')
#echo $TODAY
TODAY=''                                      # too long filename and too many files, not use date for now:

PPATH='/home/pi/Pictures/'

WIDTH='2592'
HIGHT='2944'
RES=' -w '$WIDTH' -h '$HIGHT
RESn='_w'$WIDTH'_h'$HIGHT

FUL='1.00'
MID='0.50'
QAD='0.25'
NUL='0.00'

#CMD='raspistill -vf -n '
CMD='raspistill -n '

function snap_and_show {
  ROI=' --roi '$RX0','$RY0','$RXW','$RYW                                    #echo $ROI
  ROIn='_roi_'$RX0'_'$RY0'_'$RXW'_'$RYW                                      #echo $ROIn
  PNAME=$PPATH'RPIcam_'$TODAY$RESn$ROIn'.jpg';        echo $PNAME
  $CMD$RES $ROI -o $PNAME
  gpicview $PNAME &
}

# FULL
RX0=$NUL
RY0=$NUL
RXW=$FUL
RYW=$FUL
snap_and_show

# TOP LEFT
RX0=$NUL
RY0=$NUL
RXW=$MID
RYW=$MID
snap_and_show

# TOP RIGHT
RX0=$MID
RY0=$NUL
RXW=$MID
RYW=$MID
snap_and_show

# MID LEFT
RX0=$NUL
RY0=$MID
RXW=$MID
RYW=$MID
snap_and_show

# MID RIGHT
RX0=$MID
RY0=$MID
RXW=$MID
RYW=$MID
snap_and_show

# TEST LEFT HALF
RX0=$NUL
RY0=$NUL
RXW=$MID
RYW=$FUL
snap_and_show

# TEST RIGHT HALF
RX0=$MID
RY0=$NUL
RXW=$MID
RYW=$FUL
snap_and_show

echo 'end RPIcam ROI snap'
echo 'press ENTER'
read

jcozar87
Posts: 5
Joined: Sat Apr 29, 2017 6:02 pm

Re: raspistill --roi unexpected behaviour

Sat Apr 14, 2018 6:15 pm

Oh, thank you @gordon77! I misunderstood the documentation.

However, I feel myself a bit "limited" by using it in this way. For example, let's say that I want to "split" the image into two halfs (top and bottom) and get only the bottom part. Would it be possible? Because modifying the resolution just "removes" the area equally from top and bottom, and zoom modifies the aspect ratio (if only change the y or h parameters).

Return to “Troubleshooting”