- morning panick victory
[The-Artvertiser.git] / artvertiser / multigrab.h
blob566b20ed82d1c3fc1b4c089c957c3fc1a6a1f800
1 #ifndef _MULTIGRAB_H
2 #define _MULTIGRAB_H
4 #include "calibmodel.h"
6 #define USE_MULTITHREADCAPTURE
8 #include "multithreadcapture.h"
10 class MultiGrab {
11 public:
13 CalibModel model;
15 //MultiGrab(const char *modelfile="model.bmp") : model(modelfile) {}
16 MultiGrab() {};
17 ~MultiGrab();
19 int init( char *avi_bg_path,
20 int capture_width, int capture_height, int v4l_device, int detect_width, int detect_height,
21 int desired_capture_fps );
22 /// load or train the cache using the given modelfile. if wants_training is true, train;
23 /// otherwise try to load and if load files, train
24 bool loadOrTrainCache( bool wants_training, const char* modelfile, bool running_on_binoculars = false );
26 void allocLightCollector();
28 class Cam {
29 public:
30 CvCapture *cam;
31 int width,height;
32 int detect_width, detect_height;
33 //PlanarObjectDetector detector;
34 planar_object_recognizer detector;
35 LightCollector *lc;
36 MultiThreadCapture *mtc;
38 /// stop capturing but leave frame buffers in place
39 void shutdownMultiThreadCapture();
41 const FTime& getLastProcessedFrameTimestamp() { return detected_frame_timestamp; }
42 unsigned int getFrameIndexForTime( const FTime& timestamp ) { return mtc->getFrameIndexForTime( timestamp ); }
43 IplImage* getLastProcessedFrame() { return frame; }
44 /// fetch the last raw frame + timestamp and put into *frame + timestamp. if *frame is NULL, create.
45 bool getLastDrawFrame( IplImage** raw_frame, FTime* timestamp=NULL )
46 { return mtc->getLastDrawFrame( raw_frame, timestamp, true /*block*/ ); }
48 void setCam(CvCapture *c, int capture_width, int capture_height, int detect_width, int detect_height, int desired_capture_fps );
49 bool detect( bool& frame_retrieved, bool &detect_succeeded );
51 Cam(CvCapture *c=0, int _width=0, int _height=0, int _detect_width=320, int _detect_height=240, int desired_capture_fps=20 )
53 frame = 0;
54 width=0;
55 height=0;
56 detect_width=_detect_width;
57 detect_height=_detect_height;
58 cam=0;
59 lc=0;
60 mtc=0;
61 if (c) setCam(c, _width, _height, _detect_width, _detect_height, desired_capture_fps );
62 gray=0;
63 frame_detectsize=0;
65 Cam( const Cam& other ) { assert( false && "copy constructor called, arrgh" ); }
66 ~Cam();
68 private:
69 IplImage *frame, *frame_detectsize, *gray;
70 FTime detected_frame_timestamp;
74 std::vector<Cam *> cams;
75 struct Cam *foo;
78 bool add_detected_homography(int n, planar_object_recognizer &detector, CamCalibration &calib);
79 bool add_detected_homography(int n, planar_object_recognizer &detector, CamAugmentation &a);
80 IplImage *myQueryFrame(CvCapture *capture);
81 IplImage *myRetrieveFrame(CvCapture *capture);
83 #endif