OSXでOpenCVのテスト
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 <cstdlib> | |
#include <opencv2/opencv.hpp> | |
int main(int argc, char* argv[]) { | |
cv::VideoCapture cap(0); | |
if (!cap.isOpened()) { | |
std::cerr << "Cannot open camera device." << std::endl; | |
exit(1); | |
} | |
const char* wCapture = "Capture"; | |
cv::namedWindow(wCapture, cv::WINDOW_AUTOSIZE); | |
int ksizeMinus1 = 12; | |
cv::createTrackbar("ksize-1", wCapture, &ksizeMinus1, 30); | |
cv::Mat frame; | |
cap >> frame; | |
int width = frame.cols; | |
int height = frame.rows; | |
cv::Rect r(cv::Point(width / 4, height / 4), cv::Point(3 * width / 4, 3 * height / 4)); | |
while (1) { | |
cap >> frame; | |
int ksize = ksizeMinus1 + 1; | |
cv::Mat target = frame(r); | |
cv::blur(target, target, cv::Size(ksize, ksize)); | |
cv::imshow(wCapture, frame); | |
if (cv::waitKey(30) == 0x1B) { | |
break; | |
} | |
} | |
cv::destroyAllWindows(); | |
return 0; | |
} |
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
CXX=clang++ | |
CXXFLAGS=-Wall | |
LDLIBS=-lopencv_core -lopencv_highgui -lopencv_imgproc | |
capture: capture.cpp | |
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment