Image Sizes

2 posts / 0 new
Last post
Jamie
Jamie's picture
Image Sizes

Has anyone tried changing the size of the images that are processed?

I'm guessing that changing these two variables in settings.py should be the only thing needed, but I've only tried it in the simulator and it produced some strange results. It swerves all over the place. I've attached an example.

imageWidth   = 160					# Camera image width
imageHeight  = 120					# Camera image height

Anyone have any suggestions/tips they'd be willing to share?

Images: 
Arron Churchill
Arron Churchill's picture
Lane width → trackSepX

There is another value you will need to change as well:

trackSepX = 85						# Number of pixels between two lines at offsetTargetY

Put simply trackSepX is the approximate width of a single lane in pixels. This is used to figure out how far the robot is from the centre of the track. As this will likely be too small for a larger image the robot thinks it is further away than it is, causing the excessive steering corrections.

In most cases you should be able to scale the existing number by the ratio between the new and old image widths. For example if changing to a resolution of 320 x 240:

85 × (320 ÷ 160) = 85 × 2 = 170

If you change the aspect ratio you may need to actually measure the width of the lanes in pixels at the relevant position in the image to get an accurate figure. In this case the simulator will likely not be representative of the Pi Camera.

On a side note if you are changing the camera resolution or frame rate be sure to check the supported modes from the Pi Camera V2 (see here). The camera seems to favour lower # modes in the chart as long as they match in aspect ratio and frame rate (not exceeding the resolution), the hardware / firmware / driver does the down-scaling to the exact resolution for you. In particular if the aspect ratio and frame rate you ask for results in a partial FoV you will get a very zoomed in image!

For reference the standard settings use mode #4:

  • Raw resolution: 1640x1232
  • Aspect ratio: 4:3
  • Frame rates: 0.1-40fps
  • Video mode only
  • Field of view: Full
  • Binning: 2x2

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.