RDS
Posts: 776
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Size of Preview Picture

Tue Mar 14, 2017 11:35 pm

I am using VNC and I have some (Python 3) code that includes the following lines.

Code: Select all

camera.start_preview()
time.sleep(20)
camera.capture
camera.stop_preview()
The preview image covers the entire VNC screen and is therefore really poor quality, however, the actual picture that is saved to file, when viewed, is a lot smaller and looks perfect.

Is there any way I can prevent the 'preview' image being so large. Ideally, I would like it to be the same size as the picture that is saved to file.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Size of Preview Picture

Wed Mar 15, 2017 12:15 pm

start_preview takes parameters to pass into the PiPreviewRenderer
https://picamera.readthedocs.io/en/late ... pirenderer

Code: Select all

class picamera.PiRenderer(parent, layer=0, alpha=255, fullscreen=True, window=None, crop=None, rotation=0, vflip=False, hflip=False)
so

Code: Select all

start_preview(fullscreen=False,window=(100,200,300,400))
should put it at (100,200) with width/height 300x400. Amend numbers to suit.
Last edited by 6by9 on Wed Mar 15, 2017 2:02 pm, edited 1 time in total.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

RDS
Posts: 776
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Size of Preview Picture

Wed Mar 15, 2017 1:34 pm

@6by9
Thank you very much. That is just what I needed.
(I found that another close bracket was needed at the end of the start_preview line of code, just in case anyone else requires the same solution)

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9069
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Size of Preview Picture

Wed Mar 15, 2017 2:02 pm

RDS wrote:@6by9
Thank you very much. That is just what I needed.
Documentation is a wonderful thing, and waveform80 has done a very good job on it.
RDS wrote:(I found that another close bracket was needed at the end of the start_preview line of code, just in case anyone else requires the same solution)
Edited.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

RDS
Posts: 776
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Size of Preview Picture

Wed Mar 15, 2017 11:43 pm

@6by9
This is so powerful.
I have taken it a step further now on another Pi I have that controls a NOIR camera inside the lid of my Solar Panel Meter.
It takes pictures of the meter from a cron job and until now, the picture it took was always a large picture with the actual meter shown in the middle. I have now added the 'crop' parameter so the picture now just shows the actual figures.
Thanks again.

Return to “Camera board”