#include <opencv2/imgproc.hpp> #include <opencv2/highgui.hpp> #include <iostream> //#define DEBUG #define REFERENCE_FRAME_DELAY 60 ImageProcessing::ImageProcessing(int camID, ImageSource* src, CameraParams* cam, ObjectDetection* objDet, IntraSystemMessaging* intMsg) : cameraID(camID), capture(src), camParams(cam), objectDet(objDet), internalCom(intMsg) { cv::Mat frame; *capture >> frame; camParams->initGlobalMask(frame); std::cout << "camera " << camID << ": waiting for reference frame...\n" << std::flush; cv::namedWindow("reference frame", cv::WINDOW_AUTOSIZE); for (int i = 0; i < REFERENCE_FRAME_DELAY; i++) { *capture >> frame; camParams->addGlobalMaskToFrame(frame); imshow("reference frame", frame); if (cv::waitKey(1) >= 0) { break; } } objectDet->setReferenceFrame(frame); std::cout << "camera " << camID << ": reference frame set\n" << std::flush; cv::destroyWindow("reference frame"); } void ImageProcessing::evaluate() { cv::Mat frame; Status status = OK; PxPosList pxPositions; VectRayList objectRayList; *capture >> frame; camParams->addGlobalMaskToFrame(frame); status = objectDet->detect(frame, pxPositions); #ifdef DEBUG PxPos pixelPos = pxPositions[0]; if (status != ERR) { circle(frame, cv::Point(pixelPos.x, pixelPos.y), 20, cv::Scalar(255, 0, 0), 2); circle(frame, cv::Point(pixelPos.x, pixelPos.y), 24, cv::Scalar(0, 0, 0), 2); } imshow("tracking", frame); #endif for (PxPos pixel : pxPositions) { PxPos undistorted; VectRay objectRay; camParams->undistort(pixel, undistorted); camParams->calcObjRay(undistorted, objectRay); objectRayList.push_back(objectRay); } /* * send data */ IntraSysMsg message{cameraID, objectRayList, status}; internalCom->send(message); }

some space

following soon(er or later)
home base