ECE4960-TS3-Archive/cv_code/cv_code.cpp
///////////////////////SUB THREAD///////////////////////////
//for high frame rates you will process images here the main function will allow interactions and display only
SUB THREAD
for high frame rates you will process images here the main function will allow interactions and display only
SUB THREAD for high frame rates you will process images here the main function will allow interactions and display only
int camera_thread(Mat *Frame){
	clock_t StartTime, EndTime;
	bool CamParam = 0;
	CLEyeCameraInstance EyeCamera;
	VideoCapture cap;
	Mat cur_frame = Mat(480, 640, CV_8UC4);
	if (flag_use_laptop_cam == FALSE) {
		EyeCamera = CLEyeCreateCamera(CLEyeGetCameraUUID(0), CLEYE_COLOR_RAW, RESOLUTION, FRAME_RATE);
		CLEyeCameraStart(EyeCamera);
	}
	else {
		cap.open(0 + CV_CAP_ANY);
		cap.set(CV_CAP_PROP_FPS, FRAME_RATE);
	}
	while (1) {
		if (is_camera_close == 1) break;
		if (flag_use_laptop_cam == FALSE) {
			CLEyeCameraGetFrame(EyeCamera, cur_frame.data);
		}
		else {
			cap.read(cur_frame);
		}
		if (FramerCounter == 0)StartTime = clock();
		FramerCounter++;
		EndTime = clock();
			*Frame = cur_frame;
		if ((EndTime - StartTime) / CLOCKS_PER_SEC >= 1) {
			curr_fps = FramerCounter;
			cout << "FPS:" << FramerCounter << endl;
			FramerCounter = 0;
		}
	}
	if (flag_use_laptop_cam = FALSE) {
		CLEyeCameraStop(EyeCamera);
		CLEyeDestroyCamera(EyeCamera);
		EyeCamera = NULL;
	}
	return 0;
}
int camera_thread ( Mat * Frame ) { clock_t StartTime , EndTime ; bool CamParam = 0 ; CLEyeCameraInstance EyeCamera ; VideoCapture cap ; Mat cur_frame = Mat ( 480 , 640 , CV_8UC4 ) ; if ( flag_use_laptop_cam == FALSE ) { EyeCamera = CLEyeCreateCamera ( CLEyeGetCameraUUID ( 0 ) , CLEYE_COLOR_RAW , RESOLUTION , FRAME_RATE ) ; CLEyeCameraStart ( EyeCamera ) ; } else { cap . open ( 0 + CV_CAP_ANY ) ; cap . set ( CV_CAP_PROP_FPS , FRAME_RATE ) ; } while ( 1 ) { if ( is_camera_close == 1 ) break ; if ( flag_use_laptop_cam == FALSE ) { CLEyeCameraGetFrame ( EyeCamera , cur_frame . data ) ; } else { cap . read ( cur_frame ) ; } if ( FramerCounter == 0 ) StartTime = clock ( ) ; FramerCounter ++ ; EndTime = clock ( ) ; * Frame = cur_frame ; if ( ( EndTime - StartTime ) / CLOCKS_PER_SEC >= 1 ) { curr_fps = FramerCounter ; cout << " " << FramerCounter << endl ; FramerCounter = 0 ; } } if ( flag_use_laptop_cam = FALSE ) { CLEyeCameraStop ( EyeCamera ) ; CLEyeDestroyCamera ( EyeCamera ) ; EyeCamera = NULL ; } return 0 ; }
SUB THREAD
for high frame rates you will process images here the main function will allow interactions and display only
SUB THREAD for high frame rates you will process images here the main function will allow interactions and display only
//GUID CameraID; // Track FPS //if (FramerCounter == 5) { //}