2 Copyright 2008, 2009, 2010 Julian Oliver <julian@julianoliver.com>
3 and Damian Stewart <damian@frey.co.nz>, based on BazAR which is
4 Copyright 2005, 2006 Computer Vision Lab, 3 Ecole Polytechnique
5 Federale de Lausanne (EPFL), Switzerland.
6 Distributed under the terms of the GNU General Public License v3.
8 This file is part of The Artvertiser.
10 The Artvertiser is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 The Artvertiser is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with The Artvertiser. If not, see <http://www.gnu.org/licenses/>.
27 #include "calibmodel.h"
29 #define USE_MULTITHREADCAPTURE
31 #include "multithreadcapture.h"
38 //MultiGrab(const char *modelfile="model.bmp") : model(modelfile) {}
42 int init( char *avi_bg_path
,
43 int capture_width
, int capture_height
, int v4l_device
, int detect_width
, int detect_height
,
44 int desired_capture_fps
);
45 /// load or train the cache using the given modelfile. if wants_training is true, train;
46 /// otherwise try to load and if load files, train
47 bool loadOrTrainCache( bool wants_training
, const char* modelfile
, bool train_on_binoculars
);
49 void allocLightCollector();
55 int detect_width
, detect_height
;
56 //PlanarObjectDetector detector;
57 planar_object_recognizer detector
;
59 MultiThreadCapture
*mtc
;
61 /// stop capturing but leave frame buffers in place
62 void shutdownMultiThreadCapture();
64 const FTime
& getLastProcessedFrameTimestamp() { return detected_frame_timestamp
; }
65 unsigned int getFrameIndexForTime( const FTime
& timestamp
) { return mtc
->getFrameIndexForTime( timestamp
); }
66 IplImage
* getLastProcessedFrame() { return frame
; }
67 /// fetch the last raw frame + timestamp and put into *frame + timestamp. if *frame is NULL, create.
68 bool getLastDrawFrame( IplImage
** raw_frame
, FTime
* timestamp
=NULL
)
69 { return mtc
->getLastDrawFrame( raw_frame
, timestamp
, true /*block*/ ); }
71 void setCam(CvCapture
*c
, int capture_width
, int capture_height
, int detect_width
, int detect_height
, int desired_capture_fps
);
72 bool detect( bool& frame_retrieved
, bool &detect_succeeded
);
74 Cam(CvCapture
*c
=0, int _width
=0, int _height
=0, int _detect_width
=320, int _detect_height
=240, int desired_capture_fps
=20 )
79 detect_width
=_detect_width
;
80 detect_height
=_detect_height
;
84 if (c
) setCam(c
, _width
, _height
, _detect_width
, _detect_height
, desired_capture_fps
);
88 Cam( const Cam
& other
) { assert( false && "copy constructor called, arrgh" ); }
92 IplImage
*frame
, *frame_detectsize
, *gray
;
93 FTime detected_frame_timestamp
;
97 std::vector
<Cam
*> cams
;
101 bool add_detected_homography(int n
, planar_object_recognizer
&detector
, CamCalibration
&calib
);
102 bool add_detected_homography(int n
, planar_object_recognizer
&detector
, CamAugmentation
&a
);
103 IplImage
*myQueryFrame(CvCapture
*capture
);
104 IplImage
*myRetrieveFrame(CvCapture
*capture
);