void Camera() { // Camera. Also updates camera servos.
		// forces default angle for shooting
		if(shootStick->GetRawButton(12)) {
			frontAngle = 60; // UPDATE WITH REAL VALUE
		}
		else {
			// Get joystick Y axis
			shooterY = shootStick->GetY();
			// add joystick axis to front and back angle
			frontAngle += shooterY; // Scaling is most likely needed. I don't know what the servo angle goes to/from, or what the shooter goes to/from
			backAngle += shooterY;
		}

		camswitch = flightStick -> GetRawButton(7);
		if(camtype == 1){
			frontCamServo -> SetAngle(frontAngle);
			camera1 -> GetImage(frame);
			imaqDrawShapeOnImage(frame, frame, { 70, 110, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
			imaqDrawShapeOnImage(frame, frame, { 95, 135, 50, 50}, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
			imaqDrawLineOnImage(frame, frame, DrawMode::IMAQ_DRAW_VALUE, {160,0}, {160,315}, 0.0f);
			imaqDrawLineOnImage(frame, frame, DrawMode::IMAQ_DRAW_VALUE, {0,120}, {395,120}, 0.0f);
			imaqDrawShapeOnImage(frame, frame, { 117, 157, 6, 6}, DrawMode::IMAQ_PAINT_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 255.0f);
		}
		else{
			backCamServo -> SetAngle(backAngle);
			camera2 -> GetImage(frame);
		}
		CameraServer::GetInstance()->SetImage(frame);
		if(camswitch == true){ // if we press the button
			if(bSeven == false){ // if the button is not pressed last iteration
				bSeven = true; // say button was pressed
				camtype = -camtype; // turn prime on or off
			}
		}
		else{
			bSeven = false; // when you let go, say the button was let go of
		}

	}
Exemple #2
0
// Feed video frams from the currently selected camera.
// Pass in the robot tick count -- it's just wasteful to
// send a frame every tick if the camera rate is slower
void Camera::Feed(int ticks) {
	if (enabled && cameraCount > 0 && ticks % 2 == 0) {
		IMAQdxError imaqError = cameras[currentCamera]->GetFrame();
		if (cameras[currentCamera]->frame != NULL) {
			if (IMAQdxErrorSuccess == imaqError) {
				int error = ImageProcessing::IVA_ProcessImage(cameras[currentCamera]->frame);
				if (error == 1) { //success
					if (overlay) {
						int x, y;
						Image *frame = cameras[currentCamera]->frame;
						imaqGetImageSize(frame, &x, &y);

						// Draw box around image. Note -- because the camera is pointing up a little, it's not a rectangle
						Point leftStart, leftEnd, rightStart, rightEnd;
						// It's just magic numbers here. See the "Feeder station image measurements.xlsx" spreadsheet
						leftStart.x = x * 0.387;
						leftStart.y = y * 0.258;
						leftEnd.x = x * 0.381;
						leftEnd.y = y * (0.258 + 0.584);
						imaqDrawLineOnImage(frame, frame,
								DrawMode::IMAQ_DRAW_VALUE, leftStart, leftEnd,
								1.0);
						rightStart.x = x * (0.387 + 0.241);
						rightStart.y = y * 0.258;
						rightEnd.x = x * (0.381 + 0.249);
						rightEnd.y = y * (0.258 + 0.584);
						imaqDrawLineOnImage(frame, frame,
								DrawMode::IMAQ_DRAW_VALUE, rightStart, rightEnd,
								1.0);
					}
					LCameraServer::GetInstance()->SetImage(
							cameras[currentCamera]->frame);
				}
			}
		}
	}
}