×

INDI Library v1.9.8 Released (29 Sep 2022)

Bi-monthly INDI Library released with new drivers and bug fixes.

Raspberrypi Camera Driver Raspistill - Searching for teammate

  • Posts: 8
  • Thank you received: 1
Hi all,

I am searching a teammate to build a driver for the Raspberry Pi Camera which would actually wrap the raspistill command line.

The base class we would have to derive from is there : link

An example of a simple CCD : link

Basically the plan is to :
  • see how to lauch a command with default parameters
  • : system("raspistill --raw .... &");
  • see how we would convert the file generated into an array of integers
  • most of the work done here github.com/illes/raspiraw/blob/master/raspi_dng.c
  • fill the PrimaryCCD.FrameBuffer with this array
  • same reference as supra

A comparable work has been done in java link

Hope to find someone interested !

PLEASE : inform me if such initiative or comparable already exists !


EDIT : my progress :
* I can compile;
* I ran a command line in the start exposure
* I worked on the commands line I will launch 'time raspiyuv -v -t 1 -w 960 -h 720 -rgb --shutter 300000 -o ~/img.rgb" gave me 3.6s while I was expecting far less (as 300000 is supposed to be a 3/10th of a second

* I read the v4l2 driver to get inspired on colors link :

Line 503 :
PrimaryCCD.setNAxis(3)

Line 1319 :
// We have RGB RGB RGB data but for FITS file we need each color in separate plane. i.e. RRR GGG BBB ..etc
             unsigned char *red   = dest;
             unsigned char *green = dest + v4l_base->getWidth() * v4l_base->getHeight() * (v4l_base->getBpp() / 8);
             unsigned char *blue  = dest + v4l_base->getWidth() * v4l_base->getHeight() * (v4l_base->getBpp() / 8) * 2;
 
             for (int i = 0; i < (int)frameBytes; i += 3)
             {
                 *(red++)   = *(src + i);
                 *(green++) = *(src + i + 1);
                 *(blue++)  = *(src + i + 2);
             }

Most of the work is done here : link

Xophe
The following user(s) said Thank You: gehelem
Last edit: 5 years 1 month ago by Christophe BONNEFOY.
5 years 1 month ago #20261

Please Log in or Create an account to join the conversation.

  • Posts: 155
  • Thank you received: 37
I'm considering writing this as well, because the v4l modes don't seem to expose the same ones that raspistill does.

In experimenting, I've come across this which github.com/Gordon999/Pi-AutoGuider seems to work better by a fair bit compared to using the v4l settings, after days of trying to mess with it, and uses most of the process you describe.

Have you started a github project or anything to work on it?
4 years 8 months ago #23955

Please Log in or Create an account to join the conversation.

  • Posts: 155
  • Thank you received: 37
github.com/james-lan/indi/tree/raspiccd

I have started some work on doing this and have gotten images. (Really crappy ones so far) using a V2 and using this library: www.uco.es/investiga/grupos/ava/node/40

After getting those images, I think I'm going to have to either make my own replacement for the library I'm using (tearing into raspistill) or use the raspistill method above.

The more I look at the Raspi cameras the more it looks as ad-hoc as the above code, but I have an understanding of it, which should let me make a decent replacement.

Updates will take a bit.... on the last reboot, the root fs on the SD apparently corrupted.
4 years 7 months ago #25223

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 1
hi,

I an cleaning my projects right now and before erasing, I share with you a bunch of code lines:

i tweeaked the example 3 in the libindi folder

/**************************************************************************************
** Client is asking us to start an exposure
***************************************************************************************/
bool SimpleCCD::StartExposure(float duration)
{
ExposureRequest = duration;
system("raspiyuv -t 1 -w 2592 -h 1944 -rgb -o /tmp/test.rgb");
// Since we have only have one CCD with one chip, we set the exposure duration of the primary CCD
PrimaryCCD.setExposureDuration(duration);

gettimeofday(&ExpStart, nullptr);

InExposure = true;

// We're done
return true;
}


void SimpleCCD::grabImage()
{
// Let's get a pointer to the frame buffer
uint8_t *image = PrimaryCCD.getFrameBuffer();

streampos size;
char * memblock;

ifstream file ("/tmp/test.rgb2", ios::in | ios::binary);

if (file.is_open())
{
file.seekg (0, ios::end);
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();

int expectedNbPixel = PrimaryCCD.getXRes() * PrimaryCCD.getYRes();

uint8_t * red = image;
uint8_t * green = image +expectedNbPixel;
uint8_t * blue = image+2*expectedNbPixel;

for(int i=0;i<expectedNbPixel;i++)
{
*(red++) = (uint8_t)(*(memblock + 3*i ));
*(green++) = (uint8_t)(*(memblock + 3*i + 1));
*(blue++) = (uint8_t)(*(memblock + 3*i + 2));
}

} //end if image exists
IDMessage(getDeviceName(), "Download complete.");

// Let INDI::CCD know we're done filling the image buffer
ExposureComplete(&PrimaryCCD);
}

wish it helps :)

regards
4 years 5 months ago #27017

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 10
Is there still an interest in pursuing this?
4 years 1 week ago #32027

Please Log in or Create an account to join the conversation.

  • Posts: 155
  • Thank you received: 37
Yeah, now that I know a bit more about INDI (from OnStep) I might pursue this, as a planetary imager. The drawback is forgetting the Pi Camera stuff.
3 years 10 months ago #34064

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 10
I followed up on the posts here and wrote a simple driver that I have been using for autoguiding. It is capable of long exposures using a stacking technique. The longest that I have tried is a 5 min exposure when the scope was parked, pointed to the north celestial pole (since it is the autoguiding camera).

I could use some help with some of the features that require programming skills that I am weak in. One of those being the video code.

I am working on documenting the install steps now, and can probably post a link in a few days and would be interested in feedback.
3 years 10 months ago #34101

Please Log in or Create an account to join the conversation.

  • Posts: 43
  • Thank you received: 10
As promised, here is the link to my proof-of-concept driver for the Raspberry Pi Camera:

github.com/jdhill-repo/indi-picamera

It is based on a modified INDI Generic CCD driver. I have built it on Raspbian, but not on Mate because I had trouble with the necessary userland build files for Raspiraw. If anyone has success with Mate, I would be interested in your results. Currently, it is only coded for the v2 camera. I went through a lot of trail and error with UV4L, Raspistill, etc before having some success with Raspiraw. It uses Linux system calls and reads the image from a non-blocking pipe.

This is just a basic approach, but hopefully at least a good start for a driver for the Raspberry Pi Camera.
The following user(s) said Thank You: Jasem Mutlaq
3 years 10 months ago #34231

Please Log in or Create an account to join the conversation.

Time to create page: 0.644 seconds