-
1For most cameras
===========================
Nota Bene
Digital cameras do a lot of processing. Try to run your camera in as manual a mode as possible. I set the Canon A520 to aperture priority and set the aperture to f-8.
===========================
The heart of this project is the ability to extract data from an image file.
For most cameras use the following procedure. For RAW images from the Raspberry Pi High Quality Camera, follow the instructions are in the next section (ie. Step 2).
To extract data from a jpg file, I have written procLaser.py
NB: the image files were created by a Canon A520. They are 2272 x 1704 pixels. Your camera is probably different.
If necessary, install imagemagick.
On the command line do:
convert img_00001.jpg -resize 2272x1704 -rotate 180 laserCylinder.jpg
You will have to change the image name. ie. img_00001.jpg becomes whatever your camera created.
Unless your image is upside down, you don't need: -rotate 180
procLaser.py relies on the Python PIL module. In Ubuntu, that module can be found in Synaptic..
On the command line you can do:
sudo apt install python-pil
Anyway, you have to install python-pil before you can use procLaser.py.
procLaser.py requires that you name your image file laserCylinder.jpg.
It produces an output file called data.txt.
On the command line do:
python getMaxVals.py
You will get a file called maxVals.txt which you can plot using gnuplot.
In gnuplot do:
plot "maxVals.txt" using 1:2 with lines
If you want to save the resulting graph, you can do:
set term png
set output "someFileName.png"
replot
-
2For the Raspberry Pi High Quality camera in RAW mode
These are the instructions for the Raspberry Pi High Quality camera in RAW mode
The command line instruction to take a picture is:
raspistill -ISO 100 -r -ss 1000000 -o img_00001.jpg
That sets ISO at the minimum value.
The exposure time is 1,000,000 us = 1 second.
The -r specifies a jpg file with RAW data.The aperture on the wide angle lens was wide open.
To process the data I have written unpack.py.
It's necessary to edit to change the file name for each image.
My program is based on this excellent article.
Note that, for the purposes of this project, I only care about the red pixels so that's all unpack.py deals with.
unpack.py produces a data file named maxVals.txt.
To graph the data in gnuplot do:
plot "maxVals.txt" using 1:2 with lines
If you want to save the graph, do:
set term png
set output "someFileName.png"
replot
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.