Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

try this:

#include "stdafx.h"
#include <opencv2/opencv.hpp>

static void my_cannyEdgeDetector(const cv::Mat& frame, cv::Mat& frame2, int threshval)
{
    cvtColor(frame, frame2, cv::COLOR_BGR2GRAY);
    Canny(frame2, frame2, threshval, threshval * 2, 3);

}

int main(int argc, char* argv[])
{
    cv::VideoCapture cap;
    std::string path = "video.avi";

    cap.open(path);

    if (!cap.isOpened())
    {
        std::cout << "Could not open reference "  << std::endl;
        return -1;
    }
    else
    {
        cv::Mat frame, frame2;

        for (;;)
        {
            cap >> frame;

            my_cannyEdgeDetector(frame, frame2, 128);

            cv::imshow("test", frame2);

            if((cv::waitKey(2) & 0xEFFFFF) == 27)//esc
                break;
        }
    }
    return 0;
}