diff --git a/MarkerMovie.MP4 b/MarkerMovie.MP4 new file mode 100644 index 0000000..7670bf2 Binary files /dev/null and b/MarkerMovie.MP4 differ diff --git a/MarkerTracking.cpp b/MarkerTracking.cpp index ace8b05..e9b707d 100644 --- a/MarkerTracking.cpp +++ b/MarkerTracking.cpp @@ -36,8 +36,8 @@ int main() { const string contoursWindow = "Contours"; const string thresholdWindow = "Threshold"; - namedWindow(contoursWindow, WINDOW_FREERATIO); - namedWindow(thresholdWindow, WINDOW_FREERATIO); + namedWindow(contoursWindow, WINDOW_AUTOSIZE); + namedWindow(thresholdWindow, WINDOW_AUTOSIZE); const string UI = "Threshold"; int threshold = 65; @@ -47,6 +47,11 @@ int main() { Mat imgFiltered; Detector detector; + //VIDEO + //VideoWriter threshOut("threshold.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), 24, Size(cap.get(3), cap.get(4))); + //VideoWriter imgOut("makerDetection.avi", VideoWriter::fourcc('M', 'J', 'P', 'G'), 24, Size(cap.get(3), cap.get(4))); + + while (cap.read(frame)) { // --- Process Frame --- @@ -63,11 +68,21 @@ int main() { imshow(contoursWindow, imgFiltered); imshow(thresholdWindow, videoStreamFrameGray); + //VIDEO + //threshOut.write(videoStreamFrameGray); + //imgOut.write(imgFiltered); + if (waitKey(10) == 27) { break; } } + cap.release(); + + //VIDEO + //threshOut.release(); + //imgOut.release(); + destroyAllWindows(); return (0); diff --git a/preview/makerDetection.avi b/preview/makerDetection.avi new file mode 100644 index 0000000..73602ee Binary files /dev/null and b/preview/makerDetection.avi differ diff --git a/src/Detector.cpp b/src/Detector.cpp index f76e728..b2bd199 100644 --- a/src/Detector.cpp +++ b/src/Detector.cpp @@ -78,7 +78,7 @@ void Detector::drawRectangle(Mat &output, contour_t contour){ correction.y += p.y; circle(output, correction, 3, Scalar(255,0,0), -1); - circle(output, p, 1, CV_RGB(0, 0, 255), -1); + //circle(output, p, 3, CV_RGB(0, 0, 255)); } sobelFilter.drawStrips(output); diff --git a/src/SobelFilter.cpp b/src/SobelFilter.cpp index 247499f..8430356 100644 --- a/src/SobelFilter.cpp +++ b/src/SobelFilter.cpp @@ -38,8 +38,6 @@ cv::Point2d SobelFilter::getSubPixelPoint(float dx, float dy, cv::Point edge, cv subPixel.x += delimiter.x; subPixel.y += delimiter.y; - - //cv::circle(input, subPixel, 2, cv::Scalar(0,0,255), -1); int pixel = samplePixel(input, subPixel); int w = m + 1; int h = n + (stripeLength >> 1); @@ -48,9 +46,7 @@ cv::Point2d SobelFilter::getSubPixelPoint(float dx, float dy, cv::Point edge, cv } } - //std::cout << p1.x << "||" << std::fabs(p1.x) << std::endl; - - cv::Sobel(iplStripe, iplStripe, CV_8U, 0, 1); + cv::Sobel(iplStripe, iplStripe, CV_8U, 1, 0); return findSubPixelPoint(iplStripe, sample); } @@ -113,8 +109,8 @@ cv::Point2d SobelFilter::findSubPixelPoint(cv::Mat iplStripe, SampleStrip strip) return edgeCenter; } - edgeCenter.x = pos * (strip.vecX.x + strip.vecY.x); - edgeCenter.y = pos * (strip.vecX.y + strip.vecY.y); + edgeCenter.x = pos + (strip.vecX.x + strip.vecY.x); + edgeCenter.y = pos + (strip.vecX.y + strip.vecY.y); return edgeCenter; }