Exemple #1
0
int main(int argc, char *argv[])
{
	Fg_Struct *fg;
	int w,h;
	double e;

	for(e = MIN_EXP; e <= MAX_EXP; e *= 10) {
		for(w = MIN_WIDTH; w <= MAX_WIDTH; w += 4) {
			for(h = MIN_HEIGHT; h <= MAX_HEIGHT; h++) {
				if(open_cam(&fg, ASYNC_SOFTWARE_TRIGGER, NUM_IMGS, w, h) == FG_OK) {
					method2(fg, NUM_IMGS, w, h, e, e);
					close_cam(fg);
				}
			}
		}
	}

	/*
				if(open_cam(&fg, GRABBER_CONTROLLED, NUM_IMGS, w, h) == FG_OK) {
					method1(fg, NUM_IMGS, w, h, EXPOSURE, EXPOSURE);
					close_cam(fg);
				}
	*/

	/*
	if(open_cam(&fg, GRABBER_CONTROLLED, NUM_IMGS, WIDTH, HEIGHT) == FG_OK) {
		method3(fg, NUM_IMGS, WIDTH, HEIGHT, EXPOSURE, FRAME_TIME);
		close_cam(fg);
	}
	*/

	return FG_OK;
}
Exemple #2
0
Capture::~Capture()
{
    delete ui;
    delete timer;
    close_cam();
    ::close(cam_fd);
    //cvReleaseCapture( &capture );  //??
}
int get_images(Fg_Struct *fg, int num_imgs)
{
	int rc;

	if(Fg_Acquire(fg, PORT_A, GRAB_INFINITE) < 0) {
		printf("acq: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
        close_cam(fg);
		return rc;
	}

	return FG_OK;
}
int main(int argc, char **argv) {
    ros::init(argc, argv, "raspicam_raw_node");

    //ros::NodeHandle pn("~");
    ros::NodeHandle n;

    camera_info_manager::CameraInfoManager c_info_man(n, "camera", "package://raspicam/calibrations/camera.yaml");
    get_status(&state_srv);

    //TODO: replace this with raspicamcontrol_parse_cmdline()?
    //    pn.param<bool>("hflip", hflip, 0);
    //    ROS_INFO("hflip: %d\n", hflip);
    //    pn.param<bool>("vflip", vflip, 0);
    //    ROS_INFO("vflip: %d\n", vflip);
    //    state_srv.camera_parameters.hflip = hflip;
    //    state_srv.camera_parameters.vflip = vflip;

    ROS_INFO("hflip: %d\n", hflip);
    ROS_INFO("vflip: %d\n", vflip);
    ROS_INFO("start: %d\n", auto_start);

    if (!c_info_man.loadCameraInfo("package://raspicam/calibrations/camera.yaml")) {
        ROS_INFO("Calibration file missing. Camera not calibrated");
    } else {
        c_info = c_info_man.getCameraInfo();
        ROS_INFO("Camera successfully calibrated");
    }
    image_pub = n.advertise<sensor_msgs::Image>("image", 1);
    camera_info_pub = n.advertise<sensor_msgs::CameraInfo>("camera_info", 1);
    ros::ServiceServer start_cam = n.advertiseService("start_capture", serv_start_cap);
    ros::ServiceServer stop_cam = n.advertiseService("stop_capture", serv_stop_cap);

    if (auto_start) {
        start_capture(&state_srv);
    }

    ros::spin();
    close_cam(&state_srv);
    return 0;
}
int open_cam(Fg_Struct **gr, int mode, int num_images, int w, int h)
{
	Fg_Struct *fg = NULL;
	FastConfigSequence mFcs;
	int rc;

	fg = Fg_Init(APPLET, PORT_A);
	if(fg == NULL) {
		printf("init: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	if(Fg_setParameter(fg, FG_TRIGGERMODE, &mode, PORT_A) < 0) {
		printf("mode: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	rc = FG_CL_DUALTAP_8_BIT;
	if(Fg_setParameter(fg, FG_CAMERA_LINK_CAMTYP, &rc, PORT_A) < 0) {
		printf("dual tap: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	if(Fg_setExsync(fg, FG_ON, PORT_A) < 0) {
		printf("sync on: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	// I don't think the next two do anything
    rc = FG_ON;
	if(Fg_setParameter(fg, FG_EXSYNCINVERT, &rc, PORT_A) < 0) {
		printf("sync invert: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

    rc = FG_ON;
	if(Fg_setParameter(fg, FG_EXSYNCPOLARITY, &rc, PORT_A) < 0) {
		printf("sync polarity: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	if(Fg_AllocMem(fg, w*h*num_images, num_images, PORT_A) == NULL) {
		printf("mem: %s\n", Fg_getLastErrorDescription(fg));
		rc = Fg_getLastErrorNumber(fg);
		close_cam(fg);
		return rc;
	}

	// FastConfig parameters

	if(FastConfigInit(PORT_A) != FG_OK) {
        printf("fc init: %s\n", Fg_getLastErrorDescription(fg));
        rc = Fg_getLastErrorNumber(fg);
        close_cam(fg);
        return rc;
    }

	// only one ROI
	mFcs.mLengthOfSequence = SEQ_LEN;
	mFcs.mRoiPagePointer = new int[SEQ_LEN];
	mFcs.mRoiPagePointer[0]	= 0;

    if(Fg_setParameter(fg, FG_FASTCONFIG_SEQUENCE, &mFcs, PORT_A) != FG_OK) {
        printf("fc seq: %s\n", Fg_getLastErrorDescription(fg));
        rc = Fg_getLastErrorNumber(fg);
        close_cam(fg);
        return rc;
    }

	*gr = fg;
	return FG_OK;
}
bool serv_stop_cap(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) {
    close_cam(&state_srv);
    return true;
}