Skip to content

Instantly share code, notes, and snippets.

Last active October 7, 2019 13:45
What would you like to do?
Exemplo de configuração e codificação usando VCPkg e CMaker
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project("Hello World OpenCV com VCPkg e CMake")
find_package(OpenCV CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE opencv_core opencv_imgproc opencv_videoio opencv_highgui)
#include <opencv2/opencv.hpp>
#include <iostream>
int main()
cv::namedWindow("raw", cv::WINDOW_AUTOSIZE);
cv::namedWindow("gray", cv::WINDOW_AUTOSIZE);
cv::namedWindow("canny", cv::WINDOW_AUTOSIZE);
cv::VideoCapture cap;;
if (!cap.isOpened())
std::cerr << "Couldn't open capture." << std::endl;
return -1;
cv::UMat bgr_frame, gray, canny;
for (;;)
cap >> bgr_frame;
if (bgr_frame.empty()) break;
cv::imshow("raw", bgr_frame);
cv::cvtColor(bgr_frame, gray, cv::COLOR_BGR2GRAY);
cv::imshow("gray", gray);
cv::Canny(gray, canny, 10, 100, 3, true);
cv::imshow("canny", canny);
char c = cv::waitKey(10);
if (c == 27) break;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment