Пример #1
0
int capture_final(capture_t *cap)
{
  int i;

  for (i = 0; i < cap->num_active; ++i) {
    dc1394_video_set_transmission(cap->cameras[i], DC1394_OFF);
    dc1394_capture_stop(cap->cameras[i]);
    dc1394_camera_free(cap->cameras[i]);
  }

  cap->num_active = 0;
  free(cap->cameras);  cap->cameras = NULL;

  if (cap->camera_list != NULL) {
    dc1394_camera_free_list(cap->camera_list);
    cap->camera_list = NULL;
  }
  cap->num_cameras = 0;

  if (cap->dc1394_cxt != NULL) {
    dc1394_free(cap->dc1394_cxt);
    cap->dc1394_cxt = NULL;
  }

  return CAPTURE_SUCCESS;
}
Пример #2
0
ofxLibdc::~ofxLibdc() {
	if(camera != NULL) {
		dc1394_capture_stop(camera);
		dc1394_camera_free(camera);
	}
	stopLibdcContext();
}
Пример #3
0
void ofxLibdc::applySettings() {
	if(camera)
		dc1394_capture_stop(camera);
		
	if(use1394b) {
		// assumes you want to run your 1394b camera at 800 Mbps
		dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B);
		dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_800);
	} else {
		dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY);
		dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_400);
	}
		
	dc1394framerate_t framerate;
	if(useFormat7) {
		videoMode = (dc1394video_mode_t) ((int) DC1394_VIDEO_MODE_FORMAT7_0 + format7Mode);
	} else {
		dc1394video_modes_t video_modes;
		dc1394_video_get_supported_modes(camera, &video_modes);
		dc1394color_coding_t coding;
		dc1394color_coding_t targetCoding = getLibdcType(imageType);
		for (int i = 0; i < video_modes.num; i++) {
			if (!dc1394_is_video_mode_scalable(video_modes.modes[i])) {
				dc1394video_mode_t curMode = video_modes.modes[i];
				dc1394_get_color_coding_from_video_mode(camera, curMode, &coding);
				unsigned int curWidth, curHeight;
				dc1394_get_image_size_from_video_mode(camera, curMode, &curWidth, &curHeight);
				if (coding == targetCoding && width == curWidth && height == curHeight) {
					videoMode = curMode;
					break;
				}
			}
			if(i == video_modes.num - 1) {
				ofLog(OF_LOG_ERROR, "Camera does not support target mode.");
				return;
			}
		}
		
		// get fastest framerate
		// todo: make this settable
		dc1394framerates_t framerates;
		dc1394_video_get_supported_framerates(camera, videoMode, &framerates);
		framerate = framerates.framerates[framerates.num - 1];
	}
	
	if(useFormat7) {
		quantizePosition();
		quantizeSize();
		dc1394_format7_set_roi(camera, videoMode, getLibdcType(imageType), DC1394_USE_MAX_AVAIL, left, top, width, height);
		unsigned int curWidth, curHeight;
		dc1394_format7_get_image_size(camera, videoMode, &curWidth, &curHeight);
	} else {
		dc1394_video_set_framerate(camera, framerate);
	}
	
	// contrary to the libdc1394 format7 demo, this should go after the roi setting
	dc1394_video_set_mode(camera, videoMode);
		
	dc1394_capture_setup(camera, OFXLIBDC_BUFFER_SIZE, DC1394_CAPTURE_FLAGS_DEFAULT);
}
Пример #4
0
void CvCaptureCAM_DC1394_v2_CPP::close()
{
    if (dcCam)
    {
        // check for fileno valid before using
        int fileno=dc1394_capture_get_fileno(dcCam);

        if (fileno>=0 && FD_ISSET(fileno, &dc1394.camFds))
            FD_CLR(fileno, &dc1394.camFds);
        dc1394_video_set_transmission(dcCam, DC1394_OFF);
        dc1394_capture_stop(dcCam);
        dc1394_camera_free(dcCam);
        dcCam = 0;
        started = false;
    }

    for (int i = 0; i < NIMG; i++)
    {
        cvReleaseImage(&img[i]);
        cvReleaseImage(&maps[i][0]);
        cvReleaseImage(&maps[i][1]);
    }
    if (frameC)
    {
        if (frameC->image)
            free(frameC->image);
        free(frameC);
        frameC = 0;
    }
}
Пример #5
0
static void pdp_dc1394_free(t_pdp_dc1394 *x)
{
    dc1394_video_set_transmission(x->camera, DC1394_OFF);
    dc1394_capture_stop(x->camera);
    dc1394_camera_free(x->camera);
    dc1394_free (x->d);
}
Пример #6
0
/*-----------------------------------------------------------------------
 *  Releases the cameras and exits
 *-----------------------------------------------------------------------*/
void cleanup_and_exit(dc1394camera_t *camera)
{
    dc1394_video_set_transmission(camera, DC1394_OFF);
    dc1394_capture_stop(camera);
    dc1394_camera_free(camera);
    exit(1);
}
Пример #7
0
void cleanup(void) {
    int i;
    for (i=0; i < numCameras; i++) {
        dc1394_video_set_transmission(cameras[i], DC1394_OFF);
        dc1394_capture_stop(cameras[i]);
    }
}
Пример #8
0
    VideoIIDC1394::~VideoIIDC1394(void)
    {
#if defined(DUNE_WITH_DC1394)
      dc1394_video_set_transmission(camera, DC1394_OFF);
      dc1394_capture_stop(camera);
      dc1394_camera_free(camera);
#endif
    }
Пример #9
0
/********************************
** Client is asking us to terminate connection to the device
*********************************/
bool Cindi_iidc::Disconnect() {
    if (dcam) {
        dc1394_capture_stop(dcam);
        dc1394_camera_free(dcam);
    }

    IDMessage(getDeviceName(), "indi-iidc disconnected successfully!");
    return true;
}
Пример #10
0
void
cleanup_cam( PGR_Cam *pgcp )
{
	if( IS_CAPTURING(pgcp) ) dc1394_capture_stop( pgcp->pc_cam_p );
	if( IS_TRANSMITTING(pgcp) )
		dc1394_video_set_transmission( pgcp->pc_cam_p, DC1394_OFF );
	/* dc1394_free_camera */
	dc1394_camera_free( pgcp->pc_cam_p );
}
Пример #11
0
gboolean
gst_dc1394_change_camera_transmission (GstDc1394 * src, gboolean on)
{
    dc1394switch_t status = DC1394_OFF;
    dc1394error_t err = DC1394_FAILURE;
    gint i = 0;

    g_return_val_if_fail (src->camera, FALSE);

    if (on) {

        status = dc1394_video_set_transmission (src->camera, DC1394_ON);

        i = 0;
        while (status == DC1394_OFF && i++ < 5) {
            g_usleep (50000);
            if (dc1394_video_get_transmission (src->camera,
                                               &status) != DC1394_SUCCESS) {
                if (status == DC1394_OFF) {
                    GST_LOG_OBJECT (src, "camera is still off , retrying");
                }
            }
        }

        if (i == 5) {
            GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
                               ("Camera doesn't seem to want to turn on!"),
                               ("Camera doesn't seem to want to turn on!"));
            return FALSE;
        }

        GST_LOG_OBJECT (src, "got transmision status ON");

    } else {

        if (dc1394_video_set_transmission (src->camera,
                                           DC1394_OFF) != DC1394_SUCCESS) {
            GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Unable to stop transmision"),
                               ("Unable to stop transmision"));
            return FALSE;
        }

        GST_LOG_OBJECT (src, "Stopping capture");

        err = dc1394_capture_stop (src->camera);
        if (err > 0) {
            GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Capture stop error : %d ",
                               err), ("Capture stop error : %d ", err));
            return FALSE;
        } else {
            GST_LOG_OBJECT (src, "Capture stoped successfully");
        }
    }

    return TRUE;
}
Пример #12
0
FWCamera::~FWCamera()
{
#ifdef AVG_ENABLE_1394_2
    dc1394_video_set_transmission(m_pCamera, DC1394_OFF);
    dc1394_capture_stop(m_pCamera);
    dc1394_camera_free(m_pCamera);
    dc1394_free(m_pDC1394);
#endif
    AVG_TRACE(Logger::category::CONFIG, Logger::severity::INFO, "Firewire camera closed.");
}
Пример #13
0
FirewireVideo::~FirewireVideo()
{
    Stop();

    // Close camera
    dc1394_video_set_transmission(camera, DC1394_OFF);
    dc1394_capture_stop(camera);
    dc1394_camera_free(camera);
    dc1394_free (d);
}
Пример #14
0
/**************************************************************************************
** Client is asking us to terminate connection to the device
***************************************************************************************/
bool FFMVCCD::Disconnect()
{
    if (dcam) {
        dc1394_capture_stop(dcam);
        dc1394_camera_free(dcam);
    }

    IDMessage(getDeviceName(), "Point Grey FireFly MV disconnected successfully!");
    return true;
}
Пример #15
0
static int dc1394_v2_close(AVFormatContext * context)
{
    struct dc1394_data *dc1394 = context->priv_data;

    dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
    dc1394_capture_stop(dc1394->camera);
    dc1394_camera_free(dc1394->camera);
    dc1394_free(dc1394->d);

    return 0;
}
Пример #16
0
void Libdc1394SequenceGrabber::stop()
{
	msg(osg::INFO) << "stop" << std::endl;

	setRunning(false);
	dc1394error_t err;
	err=dc1394_video_set_transmission(_camera, DC1394_OFF);
	checkSuccess(err, "dc1394_video_set_transmission failed");
	
	dc1394_capture_stop(_camera);
}
void Camera::stop() {

    eventLoopTimer->stop();
    stopClockPulse();
    dc1394_video_set_transmission(camera, DC1394_OFF);
    dc1394_capture_stop(camera);
    dc1394_camera_free(camera);
    dc1394_free (camDict);
    
    emit stopped();
}
Пример #18
0
CameraIIDC::~CameraIIDC(){
    // Stop camera transmission
    if(capturing)
        stopCapture();
    else
        dc1394_capture_stop(cam);

    // Gracefulle destruct the camera
    dc1394_camera_free(cam);
    dc1394_free(context);
}
Пример #19
0
//--------------------------------------------------------------------
of1394VideoGrabber::~of1394VideoGrabber()
{
	if(!failedToInit) // if the init failed, then trying to do this stuff is a very bad idea
	{		
		stopThread();
		ofSleepMillis(200);
		dc1394_video_set_transmission(camera, DC1394_OFF);
		dc1394_capture_stop(camera);
		dc1394_camera_free(camera);
		dc1394_free (d);
	}
}
Пример #20
0
void cleanup(void) {
  int i;
  for (i=0; i < numCameras; i++) {
    dc1394_video_set_transmission(cameras[i], DC1394_OFF);
    dc1394_capture_stop(cameras[i]);
  }
  if ((void *)window != NULL)
    XUnmapWindow(display,window);
  if (display != NULL)
    XFlush(display);
  if (frame_buffer != NULL)
    free( frame_buffer );
}
Пример #21
0
//--------------------------------------------------------------------
void ofxVideoGrabberPtgrey::close(){
    if (camera != NULL) {
        dc1394_video_set_transmission(camera, DC1394_OFF);
        dc1394_capture_stop(camera);
        dc1394_camera_free(camera);
    }

	if (pixels != NULL){
		delete[] pixels;
		pixels = NULL;
	}

	tex.clear();
}
Пример #22
0
void CameraIIDC::stopCapture(){

    dc1394error_t err;

    err = dc1394_video_set_transmission(cam, DC1394_OFF);
    err = dc1394_capture_stop(cam);

//    // Disable trigger
//    err=dc1394_external_trigger_set_power(cam, DC1394_OFF);
//    if (err!=DC1394_SUCCESS)
//        cerr << "libdc1394: Could not set external trigger on!";

    capturing = false;
}
Пример #23
0
int _stopCam(){
  if(camera==NULL) {
    dc1394_log_error("Camera is not initialised");
    return -1;
  }

  /*-----------------------------------------------------------------------
   *  stop data transmission
   *-----------------------------------------------------------------------*/
  err=dc1394_video_set_transmission(camera,DC1394_OFF);
  DC1394_ERR_CLN_RTN(err,_unsetupCam(),"Could not stop transmission of the camera");
  err=dc1394_capture_stop(camera);
  DC1394_ERR_CLN_RTN(err,_unsetupCam(),"Could not stop capture of the camera");
  return 0;
}
Пример #24
0
void
DisplayStatsAndExit(int sig)
{
    int i;
    fprintf(stderr,"\nFramerate statistics:\n");
    fprintf(stderr,"bin centers:\t[");
    for (i=0;i<bin_n;i++) {
        if (i==0)
            fprintf(stderr,"<");
        fprintf(stderr,"%3.1f",(float)bin_min+(float)(bin_max-bin_min)/(float)bin_n*((float)i+.5));
        if (i==bin_n-1)
            fprintf(stderr,">");
        if (i<bin_n)
            fprintf(stderr,"\t");
    }
    fprintf(stderr,"]\n");
    fprintf(stderr,"histogram:\t[");
    for (i=0;i<bin_n;i++) {
        if (bins[i]!=0)
            fprintf(stderr,"%d",bins[i]);
        else
            fprintf(stderr,"    ");
        if (i<bin_n)
            fprintf(stderr,"\t");
    }
    fprintf(stderr,"]\n");
    fprintf(stderr,"percentage:\t[");
    for (i=0;i<bin_n;i++) {
        if (bins[i]!=0)
            fprintf(stderr,"%3.1f",(float)bins[i]/nframes*100);
        else
            fprintf(stderr,"    ");
        if (i<bin_n)
            fprintf(stderr,"\t");
    }
    fprintf(stderr,"]\n");
    free(bins);

    SDL_Quit();

    dc1394_video_set_transmission(camera, DC1394_OFF);
    dc1394_capture_stop(camera);
    dc1394_camera_free (camera);
    dc1394_free(d);

    exit(0);
}
Пример #25
0
DC1394Camera::~DC1394Camera()
{
    // Stop any background image processing
    cleanup();

    LOGGER.infoStream() << m_guid << ": Turning off camera ";
    dc1394_video_set_transmission(m_camera, DC1394_OFF);
    dc1394_capture_stop(m_camera);

    // not sure why we would want to turn off the camera
    // especially since we never turn it on anywhere
    // dc1394_camera_set_power(m_camera, DC1394_OFF);

    dc1394_camera_free(m_camera);

    shutdownLibDC1394();
}
void ieee1394capture::cleanup()
{
	int32_t i;
	if (CREATED_CAMS == true)
	{
		for (i = 0; i < numCameras; i++) {
			dc1394_video_set_transmission(cameras[i], DC1394_OFF);
			dc1394_capture_stop(cameras[i]);
		}
		CREATED_CAMS=false;
	}
	if ( CREATED_BUS == true )
	{
		dc1394_free(d);
		CREATED_BUS=false;
	}
}
Пример #27
0
int main(int argc, char *argv[])
{
    dc1394camera_t * camera;
    dc1394error_t err;
    dc1394video_frame_t * frame;
    dc1394_t * d;
    dc1394camera_list_t * list;

    d = dc1394_new ();                                                     /* Initialize libdc1394 */
    if (!d)
        return 1;

    err=dc1394_camera_enumerate (d, &list);                                /* Find cameras */
    DC1394_ERR_RTN(err,"Failed to enumerate cameras");

    if (list->num == 0) {                                                  /* Verify that we have at least one camera */
        dc1394_log_error("No cameras found");
        return 1;
    }

    camera = dc1394_camera_new (d, list->ids[0].guid);                     /* Work with first camera */
    if (!camera) {
        dc1394_log_error("Failed to initialize camera with guid %llx", list->ids[0].guid);
        return 1;
    }
    dc1394_camera_free_list (list);

    err=dc1394_capture_setup(camera, 4, DC1394_CAPTURE_FLAGS_DEFAULT);     /* Setup capture */

    err=dc1394_video_set_transmission(camera, DC1394_ON);                  /* Start transmission */
    
    err=dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame);/* Capture */
    DC1394_ERR_RTN(err,"Problem getting an image");

    err=dc1394_capture_enqueue(camera, frame);                             /* Release the buffer */

    err=dc1394_video_set_transmission(camera, DC1394_OFF);                 /* Stop transmission */

    err=dc1394_capture_stop(camera);                                       /* Stop capture */

    printf("Hello World\n");                                               /* Hey, this is a HELLO WORLD program!! */

    dc1394_camera_free (camera);                                           /* cleanup and exit */
    dc1394_free (d);
    return 0;
}
void Libdc1394Grabber::cleanupCamera()
{
    closeCamera = true;
    ofxThread::stopThread();
    ofLog(OF_LOG_VERBOSE,"Stopped capture thread.");

    //this sleep seems necessary, at least on OSX, to avoid an occasional hang on exit
    ofSleepMillis(150);

    dc1394switch_t is_iso_on = DC1394_OFF;
    if(camera) {
        if (dc1394_video_get_transmission(camera, &is_iso_on)!=DC1394_SUCCESS) {
            is_iso_on = DC1394_ON; // try to shut ISO anyway
        }
        if (is_iso_on > DC1394_OFF) {
            if (dc1394_video_set_transmission(camera, DC1394_OFF)!=DC1394_SUCCESS) {
                ofLog(OF_LOG_ERROR, "Could not stop ISO transmission!");
            }
        }
    }
    ofLog(OF_LOG_VERBOSE,"Stopped ISO transmission.");

    /* cleanup and exit */
    if(cameraList)
        dc1394_camera_free_list (cameraList);
    if(camera) {
        dc1394_capture_stop(camera);
        dc1394_camera_free (camera);
        camera = NULL;
    }
    ofLog(OF_LOG_VERBOSE,"Stopped camera.");

    if(dc1394) {
        dc1394_free (dc1394);
        dc1394 = NULL;
    }

    if(pixels) {
        delete [] pixels;
        pixels = NULL;
    }

    printf("Closed!\n");
}
Пример #29
0
/*****************************************************************************
 * Close:
 *****************************************************************************/
static void Close( vlc_object_t *p_this )
{
    demux_t     *p_demux = (demux_t*)p_this;
    demux_sys_t *p_sys = p_demux->p_sys;

    /* Stop data transmission */
    if( dc1394_video_set_transmission( p_sys->camera,
                       DC1394_OFF ) != DC1394_SUCCESS )
        msg_Err( p_demux, "Unable to stop camera iso transmission" );

    /* Close camera */
    dc1394_capture_stop( p_sys->camera );

    CloseAudioDev( p_demux );

    dc1394_camera_free(p_sys->camera);
    dc1394_free(p_sys->p_dccontext);

    free( p_sys->video_device );
    free( p_sys->audio_device );
    free( p_sys );
}
Пример #30
0
    void
    VideoIIDC1394::stop(void)
    {
#if defined(DUNE_WITH_DC1394)
      dc1394error_t error_code;
      error_code = dc1394_video_set_transmission(camera, DC1394_OFF);
      if (error_code < 0)
      {
        throw std::runtime_error("Could not stop video capture");
        free(this);
        std::exit(EXIT_FAILURE);
      }
      error_code = dc1394_capture_stop(camera);
      if (error_code < 0)
      {
        throw std::runtime_error("Could not stop video capture");
        free(this);
        std::exit(EXIT_FAILURE);
      }

#endif
    }