From c314c52b19b59f0493976762c46652778bb1be86 Mon Sep 17 00:00:00 2001 From: "simon.fanetti" <simon.fanetti@etu.hesge.ch> Date: Fri, 8 May 2020 17:52:44 +0200 Subject: [PATCH] cleaning --- app.cpp | 80 ++++++++++++--------------------------------------------- 1 file changed, 16 insertions(+), 64 deletions(-) diff --git a/app.cpp b/app.cpp index 9d39c03..9c85114 100644 --- a/app.cpp +++ b/app.cpp @@ -15,8 +15,6 @@ using namespace cv; Mat coloredFrame(Mat frameDepth); void showLevel(); void showDiff(); -//vector<int> findCercleZ(Mat &rgb); -//void trackCircle(); @@ -26,7 +24,7 @@ void (*apps[2])() = {showLevel, showDiff}; int main(int argc, char *argv[]) { if(client.loadConfig()){ - std::cout << "Error : Couldn't load the configuration" << std::endl; + std::cout << "Failed to load the configuration" << std::endl; return 1; } @@ -39,33 +37,34 @@ int main(int argc, char *argv[]) apps[n]();*/ } -void showLevel() -{ - char windowName[] = "Sandbox"; +void showLevel(){ + Mat frameData; Mat colored; - Mat proj_frame; - //client.initWindowsFullScreen(); - cv::namedWindow(windowName, CV_WINDOW_AUTOSIZE); + //Mat proj_frame; + //char windowName[] = "Sandbox"; + //cv::namedWindow(windowName, CV_WINDOW_AUTOSIZE); + + client.initWindowsFullScreen(); do{ - client.getDepthFrame().copyTo(frameData); + client.getDepthFrame().copyTo(frameData); colored = coloredFrame(frameData); - colored.copyTo(proj_frame); - Mat* res = client.adjustProjection(&proj_frame); - cv::imshow(windowName, *res); + //colored.copyTo(proj_frame); + //Mat* res = client.adjustProjection(&proj_frame); + //cv::imshow(windowName, *res); - //client.showImage(&colored); + client.showImage(&colored); } while (waitKey(10) != ESCAPE_CHAR); cv::destroyAllWindows(); } -Mat coloredFrame(Mat frameDepth) -{ +Mat coloredFrame(Mat frameDepth){ + Mat depthFrameColored(frameDepth.size(), CV_8U); int width = frameDepth.cols, height = frameDepth.rows; static uint32_t histogram[0x10000]; @@ -103,6 +102,7 @@ Mat coloredFrame(Mat frameDepth) return depthFrameColored; } + void showDiff(){ /* Mat frameData; @@ -130,51 +130,3 @@ void showDiff(){ destroyAllWindows(); */ } - -/* -vector<int> findCercleZ(Mat &rgb) -{ - Mat src_gray; - cvtColor(rgb, src_gray, CV_BGR2GRAY); - /// Reduce the noise so we avoid false circle detection - GaussianBlur(src_gray, src_gray, Size(9, 9), 2, 2); - vector<Vec3f> circles; - circles.clear(); - /// Apply the Hough Transform to find the circles - //source, output, method, inverse ratio of resolution, Minimum distance between detected centers, threeshold canny, threeshold center, min radius, max radius - HoughCircles(src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows / 4, 75, 50, 0, 0); - //doit tester si le cercle est bon (rayon); - - vector<int> result; - if (!circles.empty()) - { - for (int i = 0; i < 3; i++) - { - result.push_back(round(circles[0][i])); - } - } - return result; -} - -void trackCircle() -{ - Mat frameRGB; - client.getRGBFrame(&frameRGB); - Mat frameColor(frameRGB.size(), CV_8UC3, Scalar(0, 0, 0)); - - do - { - client.getRGBFrame(&frameRGB); - vector<int> cercle = findCercleZ(frameRGB); - if (!cercle.empty()) - { - Point circlePosition(cercle[0], cercle[1]); - cv::circle(frameColor, circlePosition, 3, Scalar(0, 255, 0), -1, 8, 0); // point without transformation - cout << circlePosition.x << "x" << circlePosition.y << endl; - } - client.showImage(frameColor); - frameColor.setTo(Scalar(0,0,0)); - - } while (waitKey(100) != ESCAPE_CHAR); - destroyAllWindows(); -}*/ \ No newline at end of file -- GitLab