コード例 #1
0
void print_video_mode_info( dc1394camera_t *camera, dc1394video_mode_t mode) {
	int j;
	dc1394error_t err;

	printf("Mode: ");
	print_video_mode(mode);
	printf("\n");

	if((mode == DC1394_VIDEO_MODE_FORMAT7_0) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_1) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_2) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_3) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_4) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_5) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_6) ||
	   (mode == DC1394_VIDEO_MODE_FORMAT7_7))
	{
		dc1394format7mode_t f7mode;

		err=dc1394_format7_get_mode_info(camera, mode, &f7mode);
		if(err) {
			DC1394_ERR(err,"Could not format 7 information");
		} else {
			printf( "Image Sizes:\n"
			        "  size = %ix%i\n"
			        "  max = %ix%i\n"
			        "  pixels = %i\n",
			        f7mode.size_x, f7mode.size_y,
			        f7mode.max_size_x, f7mode.max_size_y,
			        f7mode.pixnum);

			printf( "Color:\n");
			for(j=0; j<f7mode.color_codings.num; j++) {
				printf("  [%d] coding = ", j);
				print_color_coding(f7mode.color_codings.codings[j]);
				printf("\n");
			}
			printf("  filter = ");
			print_color_filter(f7mode.color_filter);
			printf("\n");
		}

	} else {
		dc1394framerates_t framerates;
		err=dc1394_video_get_supported_framerates(camera,mode,&framerates);
		if(err) {
			DC1394_ERR(err,"Could not get frame rates");
		} else {
			printf("Frame Rates:\n");
			for(j = 0; j < framerates.num; j++) {
				uint32_t rate = framerates.framerates[j];
				float f_rate;
				dc1394_framerate_as_float(rate,&f_rate);
				printf("  [%d] rate = %f\n",j,f_rate );
			}
		}
	}

}
コード例 #2
0
/*-----------------------------------------------------------------------
 *  Prints various information about the mode the camera is in
 *-----------------------------------------------------------------------*/
void of1394VideoGrabber::print_mode_info(dc1394video_mode_t mode )
{
    int j;
	
    printf("Mode: ");
    print_format(mode);
    printf("\n");
	
    dc1394framerates_t framerates;
    dc1394error_t err;
    err=dc1394_video_get_supported_framerates(camera,mode,&framerates);
    DC1394_ERR(err,"Could not get frame rates");
	
    printf("Frame Rates:\n");
    for( j = 0; j < framerates.num; j++ ) {
        dc1394framerate_t rate = framerates.framerates[j];
        float f_rate;
        dc1394_framerate_as_float(rate,&f_rate);
        printf("  [%d] rate = %f\n",j,f_rate );
    }
	
}
コード例 #3
0
ファイル: DC1394Camera.cpp プロジェクト: JasonHagler/tortuga
void DC1394Camera::init(core::ConfigNode config, uint64_t guid)
{
    LOGGER.infoStream() << guid << ": Initializing camera ";
    m_guid = guid;

    // Grab our camera 
    m_camera = dc1394_camera_new(s_libHandle, guid);
    if (!m_camera) {
        LOGGER.errorStream() <<
            "Failed to initialize camera with guid: " << guid;
        assert(m_camera && "Couldn't initialize camera");
    }

    // Determines settings and frame size
    dc1394error_t err = DC1394_FAILURE;
    dc1394video_mode_t videoMode = DC1394_VIDEO_MODE_640x480_RGB8;
    dc1394framerate_t frameRate = DC1394_FRAMERATE_15;

    // Check for the whitebalance feature
    dc1394feature_info_t whiteBalance;
    whiteBalance.id = DC1394_FEATURE_WHITE_BALANCE;
    err = dc1394_feature_get(m_camera, &whiteBalance);
    assert(DC1394_SUCCESS == err && "Could not get white balance feature info");
    bool hasWhiteBalance = (whiteBalance.available == DC1394_TRUE);

    uint32_t uValue, vValue;
    if (hasWhiteBalance)
    {
        err = dc1394_feature_whitebalance_get_value(m_camera, &uValue, &vValue);
        LOGGER.infoStream() << m_guid
                            << ": Current U: " << uValue
                            << " V: " << vValue;
    }
    
    // Actually set the values if the user wants to
    if (config.exists("uValue") && config.exists("vValue"))
    {
        bool uAuto =
            boost::to_lower_copy(config["uValue"].asString("auto")) == "auto";
        bool vAuto =
            boost::to_lower_copy(config["vValue"].asString("auto")) == "auto";
        bool autoVal = uAuto && vAuto;

        if ((uAuto || vAuto) && !autoVal)
        {
            assert(false && "Both Whitebalance values must either be auto or manual");
        }

        if (autoVal)
        {
            setWhiteBalance(0, 0, true);
        }
        else
        {
            // Read in config values
            uint32_t u_b_value = static_cast<uint32_t>(config["uValue"].asInt());
            uint32_t v_r_value = static_cast<uint32_t>(config["vValue"].asInt());

            // Set values
            setWhiteBalance(u_b_value, v_r_value);
        }
    }
    else if (config.exists("uValue") || config.exists("vValue"))
    {
        assert(false && "Must set both the U and V values for white balance");
    }

    err = dc1394_feature_whitebalance_get_value(m_camera, &uValue, &vValue);
    LOGGER.infoStream() << m_guid
                        << ": Set U: " << uValue 
                        << " V: " << vValue;


    
    if (config.exists("brightness"))
    {
        // Read in and set values
        if (boost::to_lower_copy(config["brightness"].asString("auto")) == "auto")
        {
            setBrightness(0, true);
        }
        else
        {
            uint32_t value = static_cast<uint32_t>(config["brightness"].asInt());
            setBrightness(value);
        }
    }

    if (config.exists("exposure"))
    {
        // Read in and set values
        if (boost::to_lower_copy(config["exposure"].asString("auto")) == "auto")
        {
            setExposure(0, true);
        }
        else
        {
            uint32_t value = static_cast<uint32_t>(config["exposure"].asInt());
            setExposure(value);
        }
    }


    
    // Grab image size
    err = dc1394_get_image_size_from_video_mode(m_camera, videoMode,
                                                &m_width, &m_height);
    assert(DC1394_SUCCESS == err && "Could not get image size");
    
    float fRate;
    err = dc1394_framerate_as_float(frameRate, &fRate);
    assert(DC1394_SUCCESS == err && "Could not get framerate as float");
    m_fps = fRate;

    // Setup the capture
    err = dc1394_video_set_iso_speed(m_camera, DC1394_ISO_SPEED_400);
    assert(DC1394_SUCCESS == err && "Could not set iso speed");
           
    err = dc1394_video_set_mode(m_camera, videoMode);
    assert(DC1394_SUCCESS == err && "Could not set video mode");

    err = dc1394_video_set_framerate(m_camera, frameRate);
    assert(DC1394_SUCCESS == err && "Could not set framerate");

    // Start data transfer
    err = dc1394_video_set_transmission(m_camera, DC1394_ON);
    assert(DC1394_SUCCESS == err && "Could not start camera iso transmission");

    err = dc1394_capture_setup(m_camera, DMA_BUFFER_SIZE,
                               DC1394_CAPTURE_FLAGS_DEFAULT);
    assert(DC1394_SUCCESS == err && "Could not setup camera make sure"
           " that the video mode and framerate are supported by your camera");
}