Merge 2.4 into master

PR #2968: cce2d99 8578f9c
Fixed bug which caused crash of GPU version of feature matcher in stitcher

The bug caused crash of GPU version of feature matcher in stitcher when
we use ORB features.

PR #3236: 5947519
Check sure that we're not already below required leaf false alarm rate before continuing to get negative samples.

PR #3190
fix blobdetector

PR #3562 (part): 82bd82e
TBB updated to 4.3u2. Fix for aarch64 support.

PR #3604 (part): 091c7a3
OpenGL interop sample reworked not ot use cvconfig.h

PR #3792: afdf319
Add -L for CUDA libs path to pkg-config

Add all dirs from CUDA_LIBS_PATH as -L linker options to
OPENCV_LINKER_LIBS. These will end up in opencv.pc.

PR #3893: 122b9f8
Turn ocv_convert_to_lib_name into a function

PR #5490: ec5244a
fixed memory leak in findHomography tests

PR #5491: 0d5b739
delete video readers

PR #5574

PR #5202
This commit is contained in:
Alexander Alekhin
2015-12-08 10:24:54 +03:00
15 changed files with 210 additions and 116 deletions

View File

@@ -12,6 +12,7 @@
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2015, Itseez Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -564,6 +565,9 @@ void CV_HomographyTest::run(int)
default: continue;
}
}
delete[]src_data;
src_data = NULL;
}
}

View File

@@ -311,6 +311,10 @@ void SimpleBlobDetectorImpl::detect(InputArray image, std::vector<cv::KeyPoint>&
else
grayscaleImage = image.getMat();
if (grayscaleImage.type() != CV_8UC1) {
CV_Error(Error::StsUnsupportedFormat, "Blob detector only supports 8-bit images!");
}
std::vector < std::vector<Center> > centers;
for (double thresh = params.minThreshold; thresh < params.maxThreshold; thresh += params.thresholdStep)
{

View File

@@ -220,7 +220,11 @@ void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
descriptors1_.upload(features1.descriptors);
descriptors2_.upload(features2.descriptors);
Ptr<cuda::DescriptorMatcher> matcher = cuda::DescriptorMatcher::createBFMatcher(NORM_L2);
//TODO: NORM_L1 allows to avoid matcher crashes for ORB features, but is not absolutely correct for them.
// The best choice for ORB features is NORM_HAMMING, but it is incorrect for SURF features.
// More accurate fix in this place should be done in the future -- the type of the norm
// should be either a parameter of this method, or a field of the class.
Ptr<cuda::DescriptorMatcher> matcher = cuda::DescriptorMatcher::createBFMatcher(NORM_L1);
MatchesSet matches;

View File

@@ -166,10 +166,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
#ifdef HAVE_GSTREAMER
if (!capture)
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2,
reinterpret_cast<char *>(index));
if (!capture)
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L,
reinterpret_cast<char *>(index));
#endif
if (pref) break; // CV_CAP_VFW

View File

@@ -75,10 +75,13 @@
#if GST_VERSION_MAJOR == 0
#define COLOR_ELEM "ffmpegcolorspace"
#define COLOR_ELEM_NAME "ffmpegcsp"
#elif FULL_GST_VERSION < VERSION_NUM(1,5,0)
#define COLOR_ELEM "videoconvert"
#define COLOR_ELEM_NAME COLOR_ELEM
#else
#define COLOR_ELEM "autovideoconvert"
#define COLOR_ELEM_NAME COLOR_ELEM
#endif
void toFraction(double decimal, double &numerator, double &denominator);
@@ -142,6 +145,7 @@ protected:
gpointer data);
GstElement* pipeline;
GstElement* uridecodebin;
GstElement* v4l2src;
GstElement* color;
GstElement* sink;
#if GST_VERSION_MAJOR > 0
@@ -164,6 +168,7 @@ void CvCapture_GStreamer::init()
{
pipeline = NULL;
uridecodebin = NULL;
v4l2src = NULL;
color = NULL;
sink = NULL;
#if GST_VERSION_MAJOR > 0
@@ -368,9 +373,7 @@ void CvCapture_GStreamer::startPipeline()
if (status == GST_STATE_CHANGE_ASYNC)
{
// wait for status update
GstState st1;
GstState st2;
status = gst_element_get_state(pipeline, &st1, &st2, GST_CLOCK_TIME_NONE);
status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
}
if (status == GST_STATE_CHANGE_FAILURE)
{
@@ -619,7 +622,9 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
stream = true;
manualpipeline = true;
}
} else {
}
else
{
stream = true;
uri = g_strdup(filename);
}
@@ -640,68 +645,86 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
uridecodebin = gst_element_make_from_uri(GST_URI_SRC, uri, "src", NULL);
#endif
element_from_uri = true;
}else{
}
else
{
uridecodebin = gst_element_factory_make("uridecodebin", NULL);
g_object_set(G_OBJECT(uridecodebin), "uri", uri, NULL);
}
g_free(protocol);
if(!uridecodebin) {
if(!uridecodebin)
{
//fprintf(stderr, "GStreamer: Error opening bin: %s\n", err->message);
close();
return false;
}
}
if(manualpipeline)
if (manualpipeline)
{
GstIterator *it = NULL;
#if GST_VERSION_MAJOR == 0
it = gst_bin_iterate_sinks(GST_BIN(uridecodebin));
if(gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) {
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
#else
it = gst_bin_iterate_sinks (GST_BIN(uridecodebin));
GstIterator *it = gst_bin_iterate_elements(GST_BIN(uridecodebin));
gboolean done = FALSE;
GstElement *element = NULL;
gboolean done = false;
gchar* name = NULL;
#if GST_VERSION_MAJOR > 0
GValue value = G_VALUE_INIT;
#endif
while (!done) {
switch (gst_iterator_next (it, &value)) {
while (!done)
{
#if GST_VERSION_MAJOR > 0
switch (gst_iterator_next (it, &value))
{
case GST_ITERATOR_OK:
element = GST_ELEMENT (g_value_get_object (&value));
name = gst_element_get_name(element);
if (name){
if(strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL) {
sink = GST_ELEMENT ( gst_object_ref (element) );
done = TRUE;
}
g_free(name);
}
g_value_unset (&value);
element = GST_ELEMENT (g_value_get_object (&value));
#else
switch (gst_iterator_next (it, (gpointer *)&element))
{
case GST_ITERATOR_OK:
#endif
name = gst_element_get_name(element);
if (name)
{
if (strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL)
{
sink = GST_ELEMENT ( gst_object_ref (element) );
}
else if (strstr(name, COLOR_ELEM_NAME) != NULL)
{
color = GST_ELEMENT ( gst_object_ref (element) );
}
else if (strstr(name, "v4l") != NULL)
{
v4l2src = GST_ELEMENT ( gst_object_ref (element) );
}
g_free(name);
break;
done = sink && color && v4l2src;
}
#if GST_VERSION_MAJOR > 0
g_value_unset (&value);
#endif
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (it);
break;
gst_iterator_resync (it);
break;
case GST_ITERATOR_ERROR:
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
done = TRUE;
break;
}
}
gst_iterator_free (it);
if (!sink){
if (!sink)
{
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
#endif
pipeline = uridecodebin;
}
else
@@ -714,18 +737,23 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
gst_bin_add_many(GST_BIN(pipeline), uridecodebin, color, sink, NULL);
if(element_from_uri) {
if(!gst_element_link(uridecodebin, color)) {
if(element_from_uri)
{
if(!gst_element_link(uridecodebin, color))
{
CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n");
gst_object_unref(pipeline);
pipeline = NULL;
return false;
}
}else{
}
else
{
g_signal_connect(uridecodebin, "pad-added", G_CALLBACK(newPad), color);
}
if(!gst_element_link(color, sink)) {
if(!gst_element_link(color, sink))
{
CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n");
gst_object_unref(pipeline);
pipeline = NULL;
@@ -753,16 +781,13 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
gst_caps_unref(caps);
// For video files only: set pipeline to PAUSED state to get its duration
if (file)
{
status = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PAUSED);
status = gst_element_set_state(GST_ELEMENT(pipeline),
file ? GST_STATE_PAUSED : GST_STATE_PLAYING);
if (status == GST_STATE_CHANGE_ASYNC)
{
// wait for status update
GstState st1;
GstState st2;
status = gst_element_get_state(pipeline, &st1, &st2, GST_CLOCK_TIME_NONE);
status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
}
if (status == GST_STATE_CHANGE_FAILURE)
{
@@ -813,14 +838,9 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
fps = (double)num/(double)denom;
// GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
}
else
{
duration = -1;
width = -1;
height = -1;
fps = -1;
// GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")
stopPipeline();
}
__END__;
@@ -851,7 +871,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
if(!pipeline) {
CV_WARN("GStreamer: no pipeline");
return false;
return 0;
}
switch(propId) {
@@ -860,7 +880,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return false;
return 0;
}
return value * 1e-6; // nano seconds to milli seconds
case CV_CAP_PROP_POS_FRAMES:
@@ -868,7 +888,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return false;
return 0;
}
return value;
case CV_CAP_PROP_POS_AVI_RATIO:
@@ -876,7 +896,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return false;
return 0;
}
return ((double) value) / GST_FORMAT_PERCENT_MAX;
case CV_CAP_PROP_FRAME_WIDTH:
@@ -895,6 +915,21 @@ double CvCapture_GStreamer::getProperty( int propId ) const
case CV_CAP_PROP_CONTRAST:
case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_HUE:
if (v4l2src)
{
const gchar * propName =
propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" :
propId == CV_CAP_PROP_CONTRAST ? "contrast" :
propId == CV_CAP_PROP_SATURATION ? "saturation" :
propId == CV_CAP_PROP_HUE ? "hue" : NULL;
if (propName)
{
gint32 value32 = 0;
g_object_get(G_OBJECT(v4l2src), propName, &value32, NULL);
return value32;
}
}
case CV_CAP_PROP_GAIN:
case CV_CAP_PROP_CONVERT_RGB:
break;
@@ -911,7 +946,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
#undef FORMAT
return false;
return 0;
}
/*!
@@ -990,6 +1025,21 @@ bool CvCapture_GStreamer::setProperty( int propId, double value )
case CV_CAP_PROP_CONTRAST:
case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_HUE:
if (v4l2src)
{
const gchar * propName =
propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" :
propId == CV_CAP_PROP_CONTRAST ? "contrast" :
propId == CV_CAP_PROP_SATURATION ? "saturation" :
propId == CV_CAP_PROP_HUE ? "hue" : NULL;
if (propName)
{
gint32 value32 = cv::saturate_cast<gint32>(value);
g_object_set(G_OBJECT(v4l2src), propName, &value32, NULL);
return true;
}
}
case CV_CAP_PROP_GAIN:
case CV_CAP_PROP_CONVERT_RGB:
break;

View File

@@ -67,10 +67,11 @@ class CvCapture_Images : public CvCapture
public:
CvCapture_Images()
{
filename = 0;
filename = NULL;
currentframe = firstframe = 0;
length = 0;
frame = 0;
frame = NULL;
grabbedInOpen = false;
}
virtual ~CvCapture_Images()
@@ -92,6 +93,7 @@ protected:
unsigned length; // length of sequence
IplImage* frame;
bool grabbedInOpen;
};
@@ -100,7 +102,7 @@ void CvCapture_Images::close()
if( filename )
{
free(filename);
filename = 0;
filename = NULL;
}
currentframe = firstframe = 0;
length = 0;
@@ -113,17 +115,25 @@ bool CvCapture_Images::grabFrame()
char str[_MAX_PATH];
sprintf(str, filename, firstframe + currentframe);
if (grabbedInOpen)
{
grabbedInOpen = false;
++currentframe;
return frame != NULL;
}
cvReleaseImage(&frame);
frame = cvLoadImage(str, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
if( frame )
currentframe++;
return frame != 0;
return frame != NULL;
}
IplImage* CvCapture_Images::retrieveFrame(int)
{
return frame;
return grabbedInOpen ? NULL : frame;
}
double CvCapture_Images::getProperty(int id) const
@@ -168,6 +178,8 @@ bool CvCapture_Images::setProperty(int id, double value)
value = length - 1;
}
currentframe = cvRound(value);
if (currentframe != 0)
grabbedInOpen = false; // grabbed frame is not valid anymore
return true;
case CV_CAP_PROP_POS_AVI_RATIO:
if(value > 1) {
@@ -178,6 +190,8 @@ bool CvCapture_Images::setProperty(int id, double value)
value = 0;
}
currentframe = cvRound((length - 1) * value);
if (currentframe != 0)
grabbedInOpen = false; // grabbed frame is not valid anymore
return true;
}
CV_WARN("unknown/unhandled property\n");
@@ -280,7 +294,13 @@ bool CvCapture_Images::open(const char * _filename)
}
firstframe = offset;
return true;
// grab frame to enable properties retrieval
bool grabRes = grabFrame();
grabbedInOpen = true;
currentframe = 0;
return grabRes;
}
@@ -292,7 +312,7 @@ CvCapture* cvCreateFileCapture_Images(const char * filename)
return capture;
delete capture;
return 0;
return NULL;
}
//

View File

@@ -431,6 +431,10 @@ TEST(Videoio_Video_parallel_writers_and_readers, accuracy)
if (code == 1)
std::cerr << "Couldn't delete " << *i << std::endl;
}
// delete the readers
for (std::vector<VideoCapture *>::iterator i = readers.begin(), end = readers.end(); i != end; ++i)
delete *i;
}
#endif