ieee1394_capture.cc
来自「VC视频对象的跟踪提取原代码(vc视频监控源码)」· CC 代码 · 共 123 行
CC
123 行
///////////////////////////////////////////////////////////////////////////////// //// FILENAME : IEEE1394_Capture.cc //// AUTHOR : Nils T Siebel //// CREATED : Mon Sep 30 16:03:37 BST 2002 //// COPYRIGHT: Nils T Siebel //// //// PURPOSE : capture and store images using the IEEE1394Source class // // /////////////////////////////////////////////////////////////////////////////////#include <cstdio> // for cin, sprintf#include <cstring> // for strcasecmp#include <cctype> // for toupper#include <pthread.h> // for IEEE POSIX 1003.1c --- 1995 threads// #undef DEBUG#include "IEEE1394Source.h"#include "text_output.h"#include "Image.h" // for drawing functionsusing namespace ReadingPeopleTracker;// POSIX threading stuffbool enable_video_capture;pthread_mutex_t enable_video_capture_modification = PTHREAD_MUTEX_INITIALIZER;pthread_cond_t enable_video_capture_has_changed = PTHREAD_COND_INITIALIZER;IEEE1394Source *source;Image *image;// clear input buffer of cinvoid clear_cin(){ int buffer_size = cin.rdbuf()->in_avail(); for (buffer_size = cin.rdbuf()->in_avail(); buffer_size > 0; buffer_size--) cin.get();}void *capture_video(void *unused){ for ( ; ; ) { if (enable_video_capture == false) { pthread_mutex_lock(&enable_video_capture_modification); // while (enable_video_capture == false) { pthread_cond_wait(&enable_video_capture_has_changed, &enable_video_capture_modification); } // pthread_mutex_unlock(&enable_video_capture_modification); } image = source->get_next(); image->display(); // draw vertical lines where cropping will occur (for portrait images) // we are aiming at 432x576 images, cropping from 720x576 image->draw_in_image(); linewidth(4); RGBcolor(255,0,40); move2i((720-432) / 2 - 2, 9); draw2((720-432) / 2 - 2, 576 - 10); move2i(432 + (720-432) / 2 + 1, 9); draw2(432 + (720-432) / 2 + 1, 576 - 10); gflush(); }}int main(){ cinfo << " IEEE1394_Capture Version 1.4, part of the Reading People Tracker" << endl << " Program for capturing people's images using an IEEE1394 digital camera" << endl << " Author: Nils T Siebel. " << endl << " Copyright: (c) 2003-2005 Nils T Siebel. " << endl << " Please see the file COPYRIGHT for details. " << endl << endl; char person_name[1024]; unsigned long frame_count; unsigned long sequence_number; char dummy_string[1024]; char user_response; char image_filename[1024 + 512]; source = new IEEE1394Source(DV_QUALITY_BEST); pthread_t thread_id; int result = pthread_create(&thread_id, NULL, &capture_video, NULL); if (result != 0) { // an error occurred cerror << " Error: could not start thread for video capturing, " << " error code " << result << ". " << endl; exit(1); } cinfo << " Please enter the sequence number. This should start at 1, unless " << endl << " you have used the program before. In that case please enter the " << endl << " last valid sequence number plus 1 : "; cin >> sequence_number; enable_video_capture = true; pthread_cond_signal(&enable_video_capture_has_changed); // loop more or less forever: get person data and frame, write it to disk. for (frame_count = 1; frame_count > 0; frame_count++) { bool name_entered_correctly = false; while (name_entered_correctly == false) { cinfo << " Please enter the person's name or 籩xit
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?