Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <exception>
- #include <opencv2/highgui.hpp>
- #include "dlib/image_processing.h"
- #include "dlib/gui_widgets.h"
- #include "dlib/opencv.h"
- int main() try {
- cv::VideoCapture cap(0);
- if (!cap.isOpened()) {
- std::cerr << "cannot open web camera\n";
- }
- dlib::image_window win;
- dlib::array2d<unsigned int> gray_img;
- while (!win.is_closed()) {
- // grab image frame
- cv::Mat frame;
- if (!cap.read(frame)) {
- break;
- }
- dlib::cv_image<dlib::bgr_pixel> cimg(frame);
- dlib::assign_image(gray_img, cimg);
- win.clear_overlay();
- win.set_image(gray_img);
- }
- return 0;
- }
- catch (std::exception & ex) {
- std::cout << ex.what() << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment