Re: [libdc1394-devel] Dynamic Format 7 Parameter changes
Capture and control API for IIDC compliant cameras
Brought to you by:
ddouxchamps,
gordp
From: Damien D. <da...@do...> - 2005-06-23 02:37:06
|
Hi Paul, On Wed, 2005-06-22 at 17:07 -0500, pj...@en... wrote: > Damien, > > I can't figure out what's going on for the life of me. I've attached actual > code to show what it is I'm doing. > > When this code is run, the camera is already setup and running. It always runs > until the second time it checks the ISO status. At that point, ISO status is > always off, even though the call to start_iso_transmission always succeeds. > > Its getting a bit irritating really. I can understand that... > I'm not exactly sure what you meant by checking the max byte_per_packet. I > think I've done it right. But then again, I'm not too sure. It seems that you are already checking the bpp so this should not be the problem. To be perfectly sure replace the call for "recommended" bpp by a request for the max bpp. > Its still exhibiting the same behavior as before. That coriander can't start > ISO transmission after this code fails, but if I start and stop its receive > service, ISO transmissions start working again. Grrrrr. Another idea: the sizes that you specify might not be allowed by the camera. Some cameras only accept a very limited number of positions/sizes (Sony). You can play with coriander to see which sizes are allowed. > Oh and I must apologize for cursing you so many times while going through the > coriander source. That's OK, I do it too. Including cursing myself ;-) > All those threads just make following the execution so much fun. Yeah it's kind of ugly but it works. Somewhat. ;-) Another thing to try: after setting the camera in the 'bad state' try setting it back to the original settings (size/pos/bpp). If this unlocks the camera it means that some combination of those parameters is wrong. You can also test something more stupid: set the camera size/pos/bpp to the current values (therefor changing nothing). If it still does not work then it means the problem is somewhere else. If it works, wrong parameters are probably the cause. At last, try adding a 100ms delay between each command. Some cameras (Sony again) require 50ms delay minimum because when you change some parameters it has to recompute other registers (like the max allowed bpp). Well, I still have another idea: add some exit() statement in the StartIsoThread function. Executing coriander only up to a certain point and then launching your program might give you a clue on what resets the camera in a good state. Damien > int top, left, width, height ; > > unsigned int bpp ; > dc1394bool_t iso_status ; > string camera_interface = theConfigObject->GetCameraFrameInterface() ; > > left = 0 ; > top = 224 ; > width = 672 ; > height = 64 ; > > if( dc1394_stop_iso_transmission (_handle, _camera.node) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to stop ISO transmission.\n" ) ; > return false ; > } > > sleep( 1 ) ; > > if( dc1394_get_iso_status( _handle, _camera.node, &iso_status ) != > DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to get ISO transmission status.\n" ) ; > return false ; > } > if( iso_status ) > { > fprintf( stderr, "ERROR: ISO Transmission refuses to stop.\n" ) ; > return false ; > } > > if( dc1394_dma_unlisten (_handle, &_camera) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to stop dma listening.\n" ) ; > return false ; > } > > if( dc1394_dma_release_camera (_handle, &_camera) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to shutdown dma connection.\n" ) ; > return false ; > } > > if( dc1394_set_format7_image_position( _handle, _camera.node, _mode, 0, 0) > != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to position image at origin.\n" ) ; > return false ; > } > > if( dc1394_set_format7_image_size( _handle, _camera.node, _mode, width, > height ) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to set image size.\n" ) ; > return false ; > } > > if( dc1394_set_format7_image_position( _handle, _camera.node, _mode, left, > top) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to set image position.\n" ) ; > return false ; > } > > if( dc1394_query_format7_recommended_byte_per_packet( _handle, _camera.node, > _mode, &bpp ) != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to get maximum number of bytes per > packet.\n" ) ; > return false ; > } > > fprintf( stderr, "Recommended BPP: %d\n", bpp ) ; > > if( dc1394_set_format7_byte_per_packet( _handle, _camera.node, _mode, bpp ) > != DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to set bytes per packet.\n" ) ; > return false ; > } if ( > dc1394_dma_setup_format7_capture ( > _handle, > _camera_nodes [0], > _channel, > _mode, > _speed, > bpp, > left, > top, > width, > height, > _num_dma_buffers, > _drop_frames, > camera_interface.c_str(), > &_camera > ) > != DC1394_SUCCESS) > { > fprintf (stderr, "ERROR: Failed to setup Format 7 Capture for > focusing.\n") ; > return false ; > } > > if( dc1394_start_iso_transmission( _handle, _camera.node ) != DC1394_SUCCESS) > { > fprintf (stderr, "Unable to start camera iso transmission\n"); > return false ; > } > > if( dc1394_get_iso_status( _handle, _camera.node, &iso_status ) != > DC1394_SUCCESS ) > { > fprintf( stderr, "ERROR: Failed to get ISO transmission status.\n" ) ; > return false ; > } > > if( !iso_status ) > { > fprintf( stderr, "ERROR: ISO Transmission refuses to start.\n" ) ; > return false ; > } > > return true; > > > -- _ Damien 'Takahara' Douxchamps, PhD ('- Post-doctoral investigator //\ Image Processing Group, Nara Institute of Science and Technology V_/_ http://chihara.aist-nara.ac.jp/ |