Sunday, February 12, 2017

New toy - Raspberry Pi Camera v2.1


Capturing still images with the Raspberry Pi Camera v2.


After installing the ribbon cable and booting the Pi,

raspistill -o cam.jpg

the resulting image had resolution of 2592 x 1944

this corresponds to 5MP (the original RPI camera).

After an 

apt-get upgrade 
rpi-update


I am getting 8MP pictures, of  3280 x 2464 pixels size. This is what exiv2 is reporting:

File size       : 1701799 Bytes
MIME type       : image/jpeg
Image size      : 3280 x 2464
Camera make     : RaspberryPi
Camera model    : RP_imx219
Image timestamp : 2017:01:27 22:35:43
Image number    : 
Exposure time   : 1/8 s
Aperture        : F2
Exposure bias   : 
Flash           : No flash
Flash bias      : 
Focal length    : 3.0 mm
Subject distance: 
ISO speed       : 320
Exposure mode   : Aperture priority
Metering mode   : Center weighted average
Macro mode      : 
Image quality   : 
Exif Resolution : 3280 x 2464
White balance   : Auto
Thumbnail       : image/jpeg, 24576 Bytes



I can also issue
raspistill -o cam5.jpg --raw

The resulting image is still .jpg, but the file size has 12MB. The raw data comes after the regular jpeg data.

then, using the raw to dng tool https://github.com/illes/raspiraw
raspi_dng cam5.jpg cam5.dng



Nice.
Now, i just placed the camera on the top of the focuser tube (with eyepieces removed), and this is what the camera sees: The reflection of the primary and secondary mirrors.


Streaming video


For a quick preview, i found this methods simple to setup.
My "client" machine is a Linux Centos 7.
I found this method:
http://raspberrypi.stackexchange.com/questions/27082/how-to-stream-raspivid-to-linux-and-osx-using-gstreamer-vlc-or-netcat

I used another alternative, let Raspi start the video in listen mode
1.) On the RasPi start raspivid in 'listen' mode. This will wait for incoming connections
raspivid -t 0 -w 640 -h 480 -fps 30 -o tcp://0.0.0.0:5001 -l

2.) On my linux computer:
 nc raspberrypi 5001 | mplayer -fps 200 -demuxer h264es -

I packaged both commands on a single script which I can start from my Linux box, so I don't have to login to the RasPI
#!/bin/bash

# Video Streaming Preview from a Raspberry Pi, to a PC running Linux 
# Tested 2017-Jan, using raspivid Camera App v1.3.12

# a working, key-exchanged ssh setup is needed for this script to work

# 1.) On the RasPi, start raspivid to listen at port 5001, in background 

ssh pi@raspberrypi raspivid -t 0 -w 640 -h 480 -fps 30 -o tcp://0.0.0.0:5001 -l &

# some additional switches can be added to raspivid
# the -hf switch horizontally flips the image

# wait until the RasPi is ready listening
sleep 2


# 2.) On Linux (the box where this script is run), connect to the RasPi's port 5001 and play

nc raspberrypi 5001 | mplayer -fps 200 -demuxer h264es -

# one you stop the mplayer, the TCP connection is closed, and on the RasPi side also raspivid exits.


Mounting the camera on the telescope

I have a 130p/650 mm Newtonian telescope, with an 1.25" diameter eyepiece.
To achieve the so called 'prime focus', that is, to project the image from the secondary mirror directly to the sensor, without any optics involved, I removed the lens of the camera (counterclockwise rotation, some initial force applied).

I ordered a 3D-print of this thing which mounts perfectly the RasPi camera on the focuser:





Things to solve
- Where to place the camera when removed from the eyepiece? Maybe a magnetic support?
- How to focus?
- How to preview the stream when outside