コード例 #1
0
//Used for closing and stopping acquisition of a camera
void LHSVision::StopCamera(int camNum)
{
	if(camNum == 1)	//Camera 1 Shutdown
	{
		IMAQdxStopAcquisition(session);
		Wait(.01);
		IMAQdxCloseCamera(session);
	}
	else			//Camera 2 Shutdown
	{
		IMAQdxStopAcquisition(session2);
		Wait(.01);
		IMAQdxCloseCamera(session2);
	}
}
コード例 #2
0
ファイル: Camera.cpp プロジェクト: ligerbots/TestProject
IMAQdxError Camera::Stop() {
	// stop image acquisition
	imaqError = IMAQdxErrorSuccess;
	if (ULONG_MAX != session) {
		// Had trouble with imaqDrawTextOnImage
		//const DrawTextOptions options = {"Arial", 12, 0, 0, 0, 0, IMAQ_CENTER, IMAQ_INVERT};
		//int fontUsed;
		//imaqDrawTextOnImage(frame, frame, {120, 80}, "X", &options, &fontUsed);
		if (NULL != frame && camera == currentCamera) {
			// Would really like to make this semi-transparent, but not apparent how.
			int x, y;
			imaqGetImageSize(frame, &x, &y);
			//RGBValue color = IMAQ_RGB_YELLOW;
			//color.G = 240;
			//color.R = 240;
			//imaqOverlayOval(frame, { y/3, x/3, y/3, x/3 }, &color, IMAQ_DRAW_VALUE, NULL);
			//imaqMergeOverlay(NULL, frame, NULL, 0, NULL);
			// imaqDrawShapeOnImage(frame, frame, { y/3, x/3, y/3, x/3 }, DrawMode::IMAQ_DRAW_INVERT, ShapeMode::IMAQ_SHAPE_OVAL,0.0);
			LCameraServer::GetInstance()->SetImage(frame);
		}
		IMAQdxStopAcquisition(session);
		IMAQdxCloseCamera(session);
		printf("Camera %s closed on session %lu.\n",
				camInfo[camera].InterfaceName, session);
		session = ULONG_MAX;
	}
	return imaqError;
}
コード例 #3
0
ファイル: CameraMod.c プロジェクト: zenki2001cn/SnippetCode
int sgl_close_camera(CameraSgl *camera)
{
	IMAQdxError 	error = 0;
	
	if (camera->session_id) {
		sgl_stop_acquistion(camera);
		error = IMAQdxUnconfigureAcquisition(camera->session_id);
		
		if (error) {
			goto ERROR_MSG;
		}
		
		IMAQdxCloseCamera (camera->session_id);
		camera->session_id = 0;
		if (camera->display_win_num >= 0) {
			imaqCloseWindow(camera->display_win_num);
			camera->display_win_num = -1;
		}
		memset((void*)camera->interface_name, 0, sizeof(camera->interface_name));
		memset((void*)&camera->info, 0, sizeof(camera->info));
		camera->attached_win = NULL;
		camera->display_win = NULL;
		RectSet(&camera->rect_show, 0, 0, 0, 0);
		sgl_release_camera_data(camera);
	}

	return 0;
	
ERROR_MSG:
	sgl_camera_message_error(error, camera->error_callback);
	
	return -1;
}
コード例 #4
0
void Robot::TeleopPeriodic() {
	Scheduler::GetInstance()->Run();
	SmartDashboard::PutNumber("Arm Pos:",Robot::intakeArm->GetPos());
	SmartDashboard::PutNumber("POV:",oi->getDriveStick()->GetPOV(0));
	SmartDashboard::PutBoolean("old:",oldCameraSel);
	SmartDashboard::PutBoolean("sel:",CameraSel);
	double time = 0;
	if (oldCameraSel != CameraSel)
	{
		time = Timer::GetFPGATimestamp();
		IMAQdxStopAcquisition(session);
		IMAQdxUnconfigureAcquisition(session);
		IMAQdxCloseCamera(session);
		if (CameraSel)
			imaqError = IMAQdxOpenCamera("cam2", IMAQdxCameraControlModeController, &session);
		else
			imaqError = IMAQdxOpenCamera("cam0", IMAQdxCameraControlModeController, &session);
		if(imaqError != IMAQdxErrorSuccess) {
			DriverStation::ReportError("IMAQdxOpenCamera error: " + std::to_string((long)imaqError) + "\n");
		}
		imaqError = IMAQdxConfigureGrab(session);
		if(imaqError != IMAQdxErrorSuccess) {
			DriverStation::ReportError("IMAQdxConfigureGrab error: " + std::to_string((long)imaqError) + "\n");
		}
		IMAQdxStartAcquisition(session);
		oldCameraSel = CameraSel;
		time = time - Timer::GetFPGATimestamp();
		SmartDashboard::PutNumber("Switch:",time);
	}
//	if (CameraSel)
//		IMAQdxGrab(session2, frame, true, NULL);
//	else
	IMAQdxGrab(session, frame, true, NULL);
	if(imaqError != IMAQdxErrorSuccess) {
		DriverStation::ReportError("IMAQdxGrab error: " + std::to_string((long)imaqError) + "\n");
	} else {
		CameraServer::GetInstance()->SetImage(frame);
	}

}