Menu

#7 release function not implemented in raspicam_still and raspicam_still_cv

1.0
open
nobody
None
2014-06-04
2014-05-13
kbarni
No

The release() function is not implemented in RaspiCam_Still and RaspiCam_Still_Cv classes.

This is a problem, as there must be a possibility to start/stop the camera without destroying the Raspicam_Still object (when there is no need to use it or you want to change resolution).

Discussion

  • kbarni

    kbarni - 2014-05-27

    One more observation about this bug: the camera isn't freed at all before quitting the program. Even deleting the Raspicam_Still (or Raspicam_Still_Cv) object won't stop the camera, and any subsequent camera operations will lead to the crash of the program.

     
  • kbarni

    kbarni - 2014-06-04

    Here is a quick'n dirty implementation of the release function. It still has bugs (it seems that the image gets flipped after the first release), but it can disable the camera.

    raspicam_still_cv.cpp: add to the RaspiCam_Still_Cv::release() function:

    _impl->release();
    

    Then, add a public function to the Private_Impl_Still class called release(). Here is my implementation (in private_still_impl.cpp);

        void Private_Impl_Still::release()
        {
            if(!_isInitialized)return;
    
            // Deleting encoder
            if (encoder_pool)
            {
              mmal_port_pool_destroy(encoder->output[0], encoder_pool);
            }
    
            if (encoder)
            {
              mmal_component_destroy(encoder);
              encoder = NULL;
            }
    
            // Disabling camera
            if (camera)
                mmal_component_disable(camera);
    
            // Setting the camera number to 0xFFFFFFF turns it off
            // according to www.raspberrypi.org/viewtopic.php?f=43&t=78030
    
            mmal_port_parameter_set_int32 ( camera->control, MMAL_PARAMETER_CAMERA_NUM , 0xFFFFFFFF );
    
            _isInitialized=false;
        }
    

    I tried to use the destroyCamera function, or the mmal_destroy/disable/etc functions, but they didn't stop the camera.

     

Log in to post a comment.