Hello Naysan,
On Tue, 2005-07-19 at 11:57 -0400, Naysan D. Naderi wrote:
> Hello all,
>
> I've been receiving some errors when attempting to capture large streams
> using libdc.
> Can somebody please confirm that libdc1394 does have a problem to
> capture large streams of say 10098272 bytes per frame?
Which camera do you use?
> I have found that using a modified grab_partial_image code (attached) to
> capture a large stream allows me to only capture 1 frame. Subsequent
> calls causes the code to hang when attempting to capture a frame.
Your program seems to use non-DMA functions. Is there areason for that?
Have you tried the DMA functions? Non-DMA will be very slow with your
high-res camera. Also, no such hi-res camera was available when the code
was designed so bugs might have crept in.
Damien
> Thanks in advance for any assistance,
> Dan
> plain text document attachment (grab_partial_image_backup_July19.c)
> /**************************************************************************
> ** Title: grab partial images from camera, measure frame rate
> ** $RCSfile: grab_partial_image.c,v $
> ** $Revision: 1.4.2.12 $$Name: $
> ** $Date: 2005/05/20 08:58:58 $
> ** Copyright: LGPL $Author: ddouxchamps $
> ** Description:
> **
> ** Grab partial image from camera. Camera must be format 7
> ** (scalable image size) compatible. e.g., Basler A101f
> **
> **-------------------------------------------------------------------------
> **
> ** $Log: grab_partial_image.c,v $
> ** Revision 1.4.2.12 2005/05/20 08:58:58 ddouxchamps
> ** all constant definitions now start with DC1394_
> **
> ** Revision 1.4.2.11 2005/05/09 15:04:27 ddouxchamps
> ** fixed important f7 bug
> **
> ** Revision 1.4.2.10 2005/05/09 02:57:51 ddouxchamps
> ** first debugging with coriander
> **
> ** Revision 1.4.2.9 2005/05/09 00:48:23 ddouxchamps
> ** more fixes and updates
> **
> ** Revision 1.4.2.8 2005/05/06 01:24:46 ddouxchamps
> ** fixed a few bugs created by the previous changes
> **
> ** Revision 1.4.2.7 2005/05/06 00:13:38 ddouxchamps
> ** more updates from Golden Week
> **
> ** Revision 1.4.2.6 2005/05/02 04:37:58 ddouxchamps
> ** debugged everything. AFAIK code is 99.99% ok now.
> **
> ** Revision 1.4.2.5 2005/05/02 01:00:02 ddouxchamps
> ** cleanup, error handling and new camera detection
> **
> ** Revision 1.4.2.4 2005/04/28 14:45:11 ddouxchamps
> ** new error reporting mechanism
> **
> ** Revision 1.4.2.3 2005/04/20 08:54:02 ddouxchamps
> ** another big update. everything seem to work, except RAW capture.
> **
> ** Revision 1.4.2.2 2005/04/06 05:52:33 ddouxchamps
> ** fixed bandwidth usage estimation and missing strings
> **
> ** Revision 1.4.2.1 2005/02/13 07:02:47 ddouxchamps
> ** Creation of the Version_2_0 branch
> **
> ** Revision 1.4 2003/09/02 23:42:36 ddennedy
> ** cleanup handle destroying in examples; fix dc1394_multiview to use handle per camera; new example
> **
> ** Revision 1.3 2003/07/02 14:16:20 ddouxchamps
> ** changed total_bytes to unsigned long long int in dc1394_query_format7_total_bytes.
> **
> ** Revision 1.2 2001/09/14 08:20:43 ronneber
> ** - adapted to new dc1394_setup_format7_capture()
> ** - using times() instead of time() for more precise frame rate measurement
> **
> ** Revision 1.1 2001/07/24 13:50:59 ronneber
> ** - simple test programs to demonstrate the use of libdc1394 (based
> ** on 'samplegrab' of Chris Urmson
> **
> **
> **************************************************************************/
>
> #include <stdio.h>
> #include <libraw1394/raw1394.h>
> #include <libdc1394/dc1394_control.h>
> #include <stdlib.h>
> #include <time.h>
> #include <sys/times.h>
>
>
>
> int main(int argc, char *argv[])
> {
> FILE* imagefile;
> dc1394capture_t capture;
> dc1394camera_t *camera, **cameras=NULL;
> int numCameras;
> int i;
> unsigned int min_bytes, max_bytes;
> unsigned int actual_bytes;
> unsigned long long int total_bytes = 0;
> int RGB=0; //sets if it will be an RGB capture or a bayer16 capture
>
> int err=dc1394_find_cameras(&cameras, &numCameras);
>
> if (err!=DC1394_SUCCESS) {
> fprintf( stderr, "Unable to look for cameras\n\n"
> "Please check \n"
> " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
> " - if you have read/write access to /dev/raw1394\n\n");
> exit(1);
> }
>
> /*-----------------------------------------------------------------------
> * get the camera nodes and describe them as we find them
> *-----------------------------------------------------------------------*/
> if (numCameras<1) {
> fprintf(stderr, "no cameras found :(\n");
> exit(1);
> }
> camera=cameras[0];
> printf("working with the first camera on the bus\n");
>
> // free the other cameras
> for (i=1;i<numCameras;i++)
> dc1394_free_camera(cameras[i]);
> free(cameras);
>
> /*-----------------------------------------------------------------------
> * setup capture for format 7
> *-----------------------------------------------------------------------*/
>
> capture.handle=NULL;
>
> if( dc1394_setup_format7_capture(camera, 0, /* channel */
> DC1394_MODE_FORMAT7_1,
> DC1394_SPEED_400,
> DC1394_USE_MAX_AVAIL, //2324,/* use max packet size */
> 0, 0, /* left, top */
> 2584, 1954, //1200, 1200,//2208, 3000,//1992, 2400, /* width, height */
> &capture) != DC1394_SUCCESS)
> {
> fprintf( stderr,"unable to setup camera in format 7 mode 0 -\n"
> "check line %d of %s to make sure\n"
> "that the video mode,framerate and format are\n"
> "supported by your camera\n",
> __LINE__,__FILE__);
> dc1394_free_camera(camera);
> exit(1);
> }
>
> /*-----------------------------------------------------------------------
> * print allowed and used packet size
> *-----------------------------------------------------------------------*/
>
>
> if(RGB)
> {
> printf("Capturing YUV 422\n");
> if (dc1394_set_format7_color_coding_id(camera, DC1394_MODE_FORMAT7_1, DC1394_COLOR_CODING_YUV422)!= DC1394_SUCCESS)
> {
> printf("Error setting the color\n");
> return DC1394_FAILURE;
> }
> else
> printf("RGB changed correctly\n");
>
> }
> else
> {
> printf("Capturing raw something\n");
> if (dc1394_set_format7_color_coding_id(camera, DC1394_MODE_FORMAT7_1, DC1394_COLOR_CODING_RAW16)!= DC1394_SUCCESS)
> {
> printf("Error setting the color\n");
> return DC1394_FAILURE;
> }
> else
> printf("changed color correctly\n");
> }
>
> if (dc1394_query_format7_packet_para(camera, DC1394_MODE_FORMAT7_1, &min_bytes, &max_bytes) != DC1394_SUCCESS) { /* PACKET_PARA_INQ */
> printf("Packet para inq error\n");
> return DC1394_FAILURE;
> }
> printf( "camera reports allowed packet size from %d - %d bytes\n", min_bytes, max_bytes);
>
>
> if (dc1394_query_format7_byte_per_packet(camera, DC1394_MODE_FORMAT7_1, &actual_bytes) != DC1394_SUCCESS) {
> printf("dc1394_query_format7_byte_per_packet error\n");
> return DC1394_FAILURE;
> }
> printf( "camera reports actual packet size = %d bytes\n",
> actual_bytes);
>
> if (dc1394_query_format7_total_bytes(camera, DC1394_MODE_FORMAT7_1, &total_bytes) != DC1394_SUCCESS) {
> printf("dc1394_query_format7_total_bytes error\n");
> return DC1394_FAILURE;
> }
> printf( "camera reports total bytes per frame = %lld bytes\n", total_bytes);
>
>
> /*-----------------------------------------------------------------------
> * have the camera start sending us data
> *-----------------------------------------------------------------------*/
>
> printf("Starting ISO transmission\n");
> if (dc1394_start_iso_transmission(camera) !=DC1394_SUCCESS) {
> fprintf( stderr, "unable to start camera iso transmission\n");
> dc1394_release_capture(&capture);
> dc1394_free_camera(camera);
> exit(1);
> }
>
> /*-----------------------------------------------------------------------
> * capture one frame
> *-----------------------------------------------------------------------*/
> printf("Capture 1 frame\n");
> if (dc1394_capture(&capture,1)!=DC1394_SUCCESS) {
>
> dc1394_release_capture(&capture);
> dc1394_free_camera(camera);
> fprintf(stderr,"Error 3\n");
> exit(1);
> }
>
>
> /*-----------------------------------------------------------------------
> * Stop data transmission
> *-----------------------------------------------------------------------*/
>
> printf("Stop ISO Transmission\n");
> if (dc1394_stop_iso_transmission(camera)!=DC1394_SUCCESS) {
> printf("couldn't stop the camera?\n");
> }
>
> /*-----------------------------------------------------------------------
> * save last image as Part.pgm
> *-----------------------------------------------------------------------*/
>
> printf("Save Image\n");
> if(RGB)
> {
> imagefile=fopen("YUV422_dump.dump","w");
> //fprintf(imagefile,"P5\n%u %u\n255\n", capture.frame_width, capture.frame_height);
> fwrite((const char *)capture.capture_buffer, 1, capture.frame_height*capture.frame_width*2, imagefile);
> printf("wrote: YUV422_dump.dump\n");
> }
> else
> {
> imagefile=fopen("Bayer16_shot.raw","w");
> fwrite((const char *)capture.capture_buffer, 2,
> capture.frame_height*capture.frame_width, imagefile);
> printf("wrote: Bayer16_shot.raw\n");
> }
> printf("Close Imagefilie\n");
> fclose(imagefile);
>
>
> /*-----------------------------------------------------------------------
> * Close camera
> *-----------------------------------------------------------------------*/
> dc1394_release_capture(&capture);
> dc1394_free_camera(camera);
> return 0;
> }
--
_ Damien 'Takahara' Douxchamps, PhD
('- Post-doctoral investigator
//\ Image Processing Group, NAIST
V_/_ http://chihara.aist-nara.ac.jp/
|