Giter Club home page Giter Club logo

picam2fits's Introduction

picam2fits

This is a simple command line tool to convert, without loss of information, shots taken with the Raspberry Pi Camera v2 into FITS images. The shots must be taken with the --raw (-r) option of raspistill:

raspistill -r -o image.jpg
picam2fits image.jpg

This will generate the file image.fits, which contains four FITS extensions (plus the primary HDU, which is empty), one for each color channel: red, green, green (again), and blue. There are, indeed, two green channels because of the Bayer pattern of the camera's detector:

+--+--+--+--+--+
|BG|BG|BG|BG|BG|
|GR|GR|GR|GR|GR|
+--+--+--+--+--+
|BG|BG|BG|BG|BG|
|GR|GR|GR|GR|GR|
+--+--+--+--+--+
|BG|BG|BG|BG|BG|
|GR|GR|GR|GR|GR|
+--+--+--+--+--+

The image is shifted by half a pixel in the X and Y directions between the two green channels, and thus they provide independent information about the image. This is reflected in the WCS coordinate system, which provides the position of each pixel on the detector (in microns, from the bottom-left corner).

The output images have 1640x1232 pixels per channel, with integer values from 0 to 1023. The program will also read the JPG EXIF data to save the exposure time and date in the FITS header.

Install instructions

sudo apt-get install cmake libcfitsio-dev libexif-dev
git clone https://github.com/cschreib/picam2fits.git
cd picam2fits
mkdir build
cd build
cmake ../
make
sudo make install

Recommended camera settings and workflow

If you are interested in raw data and FITS files, you probably are working on a project that requires stable, repeatable observations. This should include first and foremost a stable camera configuration, without any of the automatic tuning that is used for casual photography. This can be achieved with the following:

ANALOG_GAIN=1.0   # >=1.0 and <=8.0
DIGITAL_GAIN=1.0  # >=1.0
EXPTIME=50000     # us

raspistill -t 1 -ex auto -ag ${ANALOG_GAIN} -dg ${DIGITAL_GAIN} \
    -awb off -drc off -ss ${EXPTIME} -r -o image.jpg

This setup offers a fixed exposure time EXPTIME (expressed in microseconds), no white balance correction or dynamic range compression, and a fixed ISO sensitivity through the choice of the analog and digital gains (this requires a recent version of raspistill, from October 2017 onwards). You may tweak ANALOG_GAIN for your observed scene, so as to make best use of the camera's 10 bit dynamic range and avoid saturation. DIGITAL_GAIN should be left equal to one since it provides no advantage over the analog gain, and using it to go beyong the maximum analog gain of 8 only makes sense when dealing with 8 bit data.

The option -t 1 disables the default 5 second delay before the image is actually captured. For even faster response, use the options -t 0 -s -fs 1 -v -o image_%d.jpg. This will leave raspistill to run continuously, with the camera ready to shoot. You can then trigger a capture at any time by sending the SIGUSR1 (10) signal to the program. To do so, simply run kill -s 10 $(pgrep raspistill). You can run this as many times as you wish, then take a last shot and terminate gracefully with kill -s 12 $(pgrep raspistill). The shots will be named image_1.jpg, image_2.jpg, and so on and so forth. You can finally convert them all to FITS files using picam2fits image_*.jpg.

picam2fits's People

Contributors

cschreib avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

picam2fits's Issues

Unable to "make" on Raspbian Stretch

I get through the cmake step:

~/picam2fits/build $ cmake ../
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type selected, default to Release (-DCMAKE_BUILD_TYPE=...)
-- Found components for CFITSIO
-- CFITSIO_INCLUDES = /usr/include
-- CFITSIO_LIBRARIES = /usr/lib/arm-linux-gnueabihf/libcfitsio.so
-- Found Exif: /usr/lib/arm-linux-gnueabihf/libexif.so (found version "0.6.21")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/picam2fits/build

But when I try to make the file I get:

~/picam2fits/build $ make
Scanning dependencies of target picam2fits
[ 50%] Building CXX object CMakeFiles/picam2fits.dir/picam2fits.cpp.o
/home/pi/picam2fits/picam2fits.cpp: In instantiation of ‘bool read_entry(ExifEntry*, ExifByteOrder, T&) [with T = double; ExifEntry = _ExifEntry]’:
/home/pi/picam2fits/picam2fits.cpp:125:33:   required from here
/home/pi/picam2fits/picam2fits.cpp:109:23: error: cannot convert ‘std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}’ to ‘bool’ in return
         return iss >> f;
                       ^
/home/pi/picam2fits/picam2fits.cpp: In instantiation of ‘bool read_entry(ExifEntry*, ExifByteOrder, T&) [with T = float; ExifEntry = _ExifEntry]’:
/home/pi/picam2fits/picam2fits.cpp:147:60:   required from here
/home/pi/picam2fits/picam2fits.cpp:109:23: error: cannot convert ‘std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}’ to ‘bool’ in return
CMakeFiles/picam2fits.dir/build.make:62: recipe for target 'CMakeFiles/picam2fits.dir/picam2fits.cpp.o' failed
make[2]: *** [CMakeFiles/picam2fits.dir/picam2fits.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/picam2fits.dir/all' failed
make[1]: *** [CMakeFiles/picam2fits.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Any ideas what I'm missing?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.