| | |
| | | in = get_image_from_stream_resize(cap, net.w, net.h, &in_img, use_webcam); |
| | | if(!in.data){ |
| | | //error("Stream closed."); |
| | | printf("Stream closed.\n"); |
| | | flag_exit = 1; |
| | | return; |
| | | } |
| | |
| | | probs = (float **)calloc(l.w*l.h*l.n, sizeof(float *)); |
| | | for(j = 0; j < l.w*l.h*l.n; ++j) probs[j] = (float *)calloc(l.classes, sizeof(float *)); |
| | | |
| | | flag_exit = 0; |
| | | |
| | | pthread_t fetch_thread; |
| | | pthread_t detect_thread; |
| | | |
| | |
| | | } |
| | | |
| | | CvVideoWriter* output_video_writer = NULL; // cv::VideoWriter output_video; |
| | | if (out_filename) |
| | | if (out_filename && !flag_exit) |
| | | { |
| | | CvSize size; |
| | | size.width = det_img->width, size.height = det_img->height; |
| | |
| | | //output_video_writer = cvCreateVideoWriter(out_filename, CV_FOURCC('X', 'V', 'I', 'D'), 25, size, 1); |
| | | //output_video_writer = cvCreateVideoWriter(out_filename, CV_FOURCC('W', 'M', 'V', '2'), 25, size, 1); |
| | | } |
| | | flag_exit = 0; |
| | | |
| | | double before = get_wall_time(); |
| | | |
| | |
| | | |
| | | |
| | | CvCapture* get_capture_webcam(int index) { |
| | | CvCapture* cap = (CvCapture*)new cv::VideoCapture(index); |
| | | CvCapture* cap = NULL; |
| | | try { |
| | | cap = (CvCapture*)new cv::VideoCapture(index); |
| | | //((cv::VideoCapture*)cap)->set(CV_CAP_PROP_FRAME_WIDTH, 1280); |
| | | //((cv::VideoCapture*)cap)->set(CV_CAP_PROP_FRAME_HEIGHT, 960); |
| | | } |
| | | catch (...) { |
| | | std::cout << " Error: Web-camera " << index << " can't be opened! \n"; |
| | | } |
| | | return cap; |
| | | } |
| | | |
| | | IplImage* get_webcam_frame(CvCapture *cap) { |
| | | cv::VideoCapture &cpp_cap = *(cv::VideoCapture *)cap; |
| | | cv::Mat frame; |
| | | cpp_cap >> frame; |
| | | IplImage* src = cvCreateImage(cvSize(frame.cols, frame.rows), 8, frame.channels()); |
| | | *src = frame; |
| | | IplImage* src = NULL; |
| | | try { |
| | | cv::VideoCapture &cpp_cap = *(cv::VideoCapture *)cap; |
| | | cv::Mat frame; |
| | | if (cpp_cap.isOpened()) { |
| | | cpp_cap >> frame; |
| | | src = cvCreateImage(cvSize(frame.cols, frame.rows), 8, frame.channels()); |
| | | *src = frame; |
| | | } |
| | | } |
| | | catch (...) { |
| | | std::cout << " Web-camera stoped! \n"; |
| | | } |
| | | return src; |
| | | } |
| | | |