From 059b79f7c2be6d8054195b77fbb0226cd7b3fee0 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Fri, 1 Jun 2012 10:59:27 +0000 Subject: [PATCH] Merged the trunk r8542:8544 --- .../include/opencv2/features2d/features2d.hpp | 4 +++- modules/features2d/src/features2d_init.cpp | 11 +++++++++-- modules/highgui/src/cap.cpp | 11 ++++------- modules/highgui/src/cap_ffmpeg_impl.hpp | 4 ++++ modules/highgui/src/cap_qtkit.mm | 4 +++- modules/video/src/video_init.cpp | 1 + 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 91795a0b3..3e49dfb8b 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -508,12 +508,14 @@ public: * gridRows Grid rows count. * gridCols Grid column count. */ - CV_WRAP GridAdaptedFeatureDetector( const Ptr& detector, + CV_WRAP GridAdaptedFeatureDetector( const Ptr& detector=0, int maxTotalKeypoints=1000, int gridRows=4, int gridCols=4 ); // TODO implement read/write virtual bool empty() const; + + AlgorithmInfo* info() const; protected: virtual void detectImpl( const Mat& image, vector& keypoints, const Mat& mask=Mat() ) const; diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 3312d9e91..6f9e07cfb 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -133,15 +133,22 @@ CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense", obj.info()->addParam(obj, "varyXyStepWithScale", obj.varyXyStepWithScale); obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale)); +CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", + obj.info()->addParam(obj, "detector", (Ptr&)obj.detector); + obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints); + obj.info()->addParam(obj, "gridRows", obj.gridRows); + obj.info()->addParam(obj, "gridCols", obj.gridCols)); + bool initModule_features2d(void) { Ptr brief = createBriefDescriptorExtractor(), orb = createORB(), star = createStarDetector(), fastd = createFastFeatureDetector(), mser = createMSER(), - dense = createDenseFeatureDetector(), gftt = createGFTTDetector(), harris = createHarrisDetector(); + dense = createDenseFeatureDetector(), gftt = createGFTTDetector(), + harris = createHarrisDetector(), grid = createGridAdaptedFeatureDetector(); return brief->info() != 0 && orb->info() != 0 && star->info() != 0 && fastd->info() != 0 && mser->info() != 0 && dense->info() != 0 && - gftt->info() != 0 && harris->info() != 0; + gftt->info() != 0 && harris->info() != 0 && grid->info() != 0; } } diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index d863431c3..8dc25f317 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -494,19 +494,16 @@ bool VideoCapture::retrieve(Mat& image, int channel) bool VideoCapture::read(Mat& image) { - if(!grab()) - image.release(); - else + if(grab()) retrieve(image); + else + image.release(); return !image.empty(); } VideoCapture& VideoCapture::operator >> (Mat& image) { - if(!grab()) - image.release(); - else - retrieve(image); + read(image); return *this; } diff --git a/modules/highgui/src/cap_ffmpeg_impl.hpp b/modules/highgui/src/cap_ffmpeg_impl.hpp index 38b369723..e27ae4347 100644 --- a/modules/highgui/src/cap_ffmpeg_impl.hpp +++ b/modules/highgui/src/cap_ffmpeg_impl.hpp @@ -438,6 +438,10 @@ bool CvCapture_FFMPEG::grabFrame() const int max_number_of_attempts = 1 << 16; if( !ic || !video_st ) return false; + + if( ic->streams[video_stream]->nb_frames > 0 && + frame_number > ic->streams[video_stream]->nb_frames ) + return false; av_free_packet (&packet); diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm index 6efe4bd21..ff5d408de 100644 --- a/modules/highgui/src/cap_qtkit.mm +++ b/modules/highgui/src/cap_qtkit.mm @@ -316,7 +316,9 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) { capture = [[CaptureDelegate alloc] init]; QTCaptureDevice *device; - NSArray* devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo]; + NSArray* devices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] + arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain]; + if ([devices count] == 0) { cout << "QTKit didn't find any attached Video Input Devices!" << endl; [localpool drain]; diff --git a/modules/video/src/video_init.cpp b/modules/video/src/video_init.cpp index 159f3075c..8f2812e89 100644 --- a/modules/video/src/video_init.cpp +++ b/modules/video/src/video_init.cpp @@ -57,6 +57,7 @@ CV_INIT_ALGORITHM(BackgroundSubtractorMOG, "BackgroundSubtractor.MOG", CV_INIT_ALGORITHM(BackgroundSubtractorMOG2, "BackgroundSubtractor.MOG2", obj.info()->addParam(obj, "history", obj.history); + obj.info()->addParam(obj, "nmixtures", obj.nmixtures); obj.info()->addParam(obj, "varThreshold", obj.varThreshold); obj.info()->addParam(obj, "detectShadows", obj.bShadowDetection));