Пример #1
0
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;
}
Пример #2
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);
	}

}