Last active
October 7, 2019 13:45
-
-
Save carlosdelfino/7bb930a705386659aa6c433c4f90d324 to your computer and use it in GitHub Desktop.
Exemplo de configuração e codificação usando VCPkg e CMaker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
cap.open(0); | |
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; | |
} | |
cap.release(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment