Commit 78a33815 authored by Andrey Kamaev's avatar Andrey Kamaev

Merge branch '2.4'

parents 013e9294 63873a83
...@@ -412,7 +412,7 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1, ...@@ -412,7 +412,7 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
cvRodrigues2( &r1, &R1, &dR1dr1 ); cvRodrigues2( &r1, &R1, &dR1dr1 );
cvRodrigues2( &r2, &R2, &dR2dr2 ); cvRodrigues2( &r2, &R2, &dR2dr2 );
if( _rvec3 || dr3dr1 || dr3dr1 ) if( _rvec3 || dr3dr1 || dr3dr2 )
{ {
double _r3[3], _R3[9], _dR3dR1[9*9], _dR3dR2[9*9], _dr3dR3[9*3]; double _r3[3], _R3[9], _dR3dR1[9*9], _dR3dR2[9*9], _dr3dR3[9*3];
double _W1[9*3], _W2[3*3]; double _W1[9*3], _W2[3*3];
......
...@@ -119,12 +119,6 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints, ...@@ -119,12 +119,6 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
float diff = (float)criteria.epsilon; float diff = (float)criteria.epsilon;
float inv_focalLength = 1 / focalLength; float inv_focalLength = 1 / focalLength;
/* init variables */
int N = pObject->N;
float *objectVectors = pObject->obj_vecs;
float *invMatrix = pObject->inv_matr;
float *imgVectors = pObject->img_vecs;
/* Check bad arguments */ /* Check bad arguments */
if( imagePoints == NULL ) if( imagePoints == NULL )
return CV_NULLPTR_ERR; return CV_NULLPTR_ERR;
...@@ -143,6 +137,12 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints, ...@@ -143,6 +137,12 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 ) if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 )
return CV_BADFACTOR_ERR; return CV_BADFACTOR_ERR;
/* init variables */
int N = pObject->N;
float *objectVectors = pObject->obj_vecs;
float *invMatrix = pObject->inv_matr;
float *imgVectors = pObject->img_vecs;
while( !converged ) while( !converged )
{ {
if( count == 0 ) if( count == 0 )
......
...@@ -584,11 +584,12 @@ cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing ...@@ -584,11 +584,12 @@ cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing
CvStringHashNode* node = 0; CvStringHashNode* node = 0;
unsigned hashval = 0; unsigned hashval = 0;
int i, tab_size; int i, tab_size;
CvStringHash* map = fs->str_hash;
if( !fs ) if( !fs )
return 0; return 0;
CvStringHash* map = fs->str_hash;
if( len < 0 ) if( len < 0 )
{ {
for( i = 0; str[i] != '\0'; i++ ) for( i = 0; str[i] != '\0'; i++ )
......
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
using namespace std; using namespace std;
using namespace cv; using namespace cv;
using namespace perf; using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; using std::tr1::get;
#ifndef ANDROID
typedef perf::TestBaseWithParam<String> VideoCapture_Reading; typedef perf::TestBaseWithParam<String> VideoCapture_Reading;
...@@ -26,4 +27,4 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_ ...@@ -26,4 +27,4 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_
SANITY_CHECK(dummy); SANITY_CHECK(dummy);
} }
#endif //ANDROID #endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
\ No newline at end of file \ No newline at end of file
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#if BUILD_WITH_VIDEO_OUTPUT_SUPPORT
using namespace std; using namespace std;
using namespace cv; using namespace cv;
using namespace perf; using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; using std::tr1::get;
#ifndef ANDROID
typedef std::tr1::tuple<String, bool> VideoWriter_Writing_t; typedef std::tr1::tuple<String, bool> VideoWriter_Writing_t;
typedef perf::TestBaseWithParam<VideoWriter_Writing_t> VideoWriter_Writing; typedef perf::TestBaseWithParam<VideoWriter_Writing_t> VideoWriter_Writing;
...@@ -31,4 +31,4 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame, ...@@ -31,4 +31,4 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
SANITY_CHECK(dummy); SANITY_CHECK(dummy);
} }
#endif //ANDROID #endif // BUILD_WITH_VIDEO_OUTPUT_SUPPORT
\ No newline at end of file \ No newline at end of file
...@@ -16,4 +16,29 @@ ...@@ -16,4 +16,29 @@
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif #endif
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \
/*defined(HAVE_OPENNI) || too specialized */ \
defined(HAVE_FFMPEG) || \
defined(WIN32) /* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#if /*defined(HAVE_XINE) || */\
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_AVFOUNDATION) || \
defined(HAVE_FFMPEG) || \
defined(WIN32) /* assume that we have ffmpeg */
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
#else
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
#endif
#endif #endif
...@@ -186,7 +186,7 @@ class CreateVideoWriterInvoker : ...@@ -186,7 +186,7 @@ class CreateVideoWriterInvoker :
public: public:
const static Size FrameSize; const static Size FrameSize;
static std::string TmpDirectory; static std::string TmpDirectory;
CreateVideoWriterInvoker(std::vector<VideoWriter*>& _writers, std::vector<std::string>& _files) : CreateVideoWriterInvoker(std::vector<VideoWriter*>& _writers, std::vector<std::string>& _files) :
ParallelLoopBody(), writers(&_writers), files(&_files) ParallelLoopBody(), writers(&_writers), files(&_files)
{ {
...@@ -221,7 +221,7 @@ class WriteVideo_Invoker : ...@@ -221,7 +221,7 @@ class WriteVideo_Invoker :
{ {
public: public:
enum { FrameCount = 300 }; enum { FrameCount = 300 };
static const Scalar ObjectColor; static const Scalar ObjectColor;
static const Point Center; static const Point Center;
...@@ -229,11 +229,11 @@ public: ...@@ -229,11 +229,11 @@ public:
ParallelLoopBody(), writers(&_writers) ParallelLoopBody(), writers(&_writers)
{ {
} }
static void GenerateFrame(Mat& frame, unsigned int i) static void GenerateFrame(Mat& frame, unsigned int i)
{ {
frame = Scalar::all(i % 255); frame = Scalar::all(i % 255);
std::string text = to_string(i); std::string text = to_string(i);
putText(frame, text, Point(50, Center.y), FONT_HERSHEY_SIMPLEX, 5.0, ObjectColor, 5, CV_AA); putText(frame, text, Point(50, Center.y), FONT_HERSHEY_SIMPLEX, 5.0, ObjectColor, 5, CV_AA);
circle(frame, Center, i + 2, ObjectColor, 2, CV_AA); circle(frame, Center, i + 2, ObjectColor, 2, CV_AA);
...@@ -245,7 +245,7 @@ public: ...@@ -245,7 +245,7 @@ public:
VideoWriter* writer = writers->operator[](range.start); VideoWriter* writer = writers->operator[](range.start);
CV_Assert(writer != NULL); CV_Assert(writer != NULL);
CV_Assert(writer->isOpened()); CV_Assert(writer->isOpened());
Mat frame(CreateVideoWriterInvoker::FrameSize, CV_8UC3); Mat frame(CreateVideoWriterInvoker::FrameSize, CV_8UC3);
for (unsigned int i = 0; i < FrameCount; ++i) for (unsigned int i = 0; i < FrameCount; ++i)
{ {
...@@ -253,7 +253,7 @@ public: ...@@ -253,7 +253,7 @@ public:
writer->operator<< (frame); writer->operator<< (frame);
} }
} }
protected: protected:
static std::string to_string(unsigned int i) static std::string to_string(unsigned int i)
{ {
......
...@@ -1212,6 +1212,7 @@ int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n, ...@@ -1212,6 +1212,7 @@ int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n,
free(tmpPartsDisplacement[i]); free(tmpPartsDisplacement[i]);
} }
free(tmpPoints); free(tmpPoints);
free(tmpPartsDisplacement);
free(tmpScore); free(tmpScore);
free(tmpKPoints); free(tmpKPoints);
......
...@@ -615,7 +615,7 @@ namespace cv ...@@ -615,7 +615,7 @@ namespace cv
CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL)); CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL));
cout << "\n\t\t\tBUILD LOG\n"; cout << "\n\t\t\tBUILD LOG\n";
cout << buildLog << endl; cout << buildLog << endl;
delete buildLog; delete [] buildLog;
} }
openCLVerifyCall(status); openCLVerifyCall(status);
} }
......
...@@ -224,9 +224,42 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow ...@@ -224,9 +224,42 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
return true; return true;
} }
if( PyInt_Check(o) )
{
double v[] = {PyInt_AsLong((PyObject*)o), 0., 0., 0.};
m = Mat(4, 1, CV_64F, v).clone();
return true;
}
if( PyFloat_Check(o) )
{
double v[] = {PyFloat_AsDouble((PyObject*)o), 0., 0., 0.};
m = Mat(4, 1, CV_64F, v).clone();
return true;
}
if( PyTuple_Check(o) )
{
int i, sz = (int)PyTuple_Size((PyObject*)o);
m = Mat(sz, 1, CV_64F);
for( i = 0; i < sz; i++ )
{
PyObject* oi = PyTuple_GET_ITEM(o, i);
if( PyInt_Check(oi) )
m.at<double>(i) = (double)PyInt_AsLong(oi);
else if( PyFloat_Check(oi) )
m.at<double>(i) = (double)PyFloat_AsDouble(oi);
else
{
failmsg("%s is not a numerical tuple", info.name);
m.release();
return false;
}
}
return true;
}
if( !PyArray_Check(o) ) if( !PyArray_Check(o) )
{ {
failmsg("%s is not a numpy array", info.name); failmsg("%s is not a numpy array, neither a scalar", info.name);
return false; return false;
} }
...@@ -236,6 +269,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow ...@@ -236,6 +269,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
typenum == NPY_BYTE ? CV_8S : typenum == NPY_BYTE ? CV_8S :
typenum == NPY_USHORT ? CV_16U : typenum == NPY_USHORT ? CV_16U :
typenum == NPY_SHORT ? CV_16S : typenum == NPY_SHORT ? CV_16S :
typenum == NPY_INT ? CV_32S :
typenum == NPY_INT32 ? CV_32S : typenum == NPY_INT32 ? CV_32S :
typenum == NPY_FLOAT ? CV_32F : typenum == NPY_FLOAT ? CV_32F :
typenum == NPY_DOUBLE ? CV_64F : -1; typenum == NPY_DOUBLE ? CV_64F : -1;
...@@ -245,7 +279,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow ...@@ -245,7 +279,7 @@ static int pyopencv_to(const PyObject* o, Mat& m, const ArgInfo info, bool allow
if( typenum == NPY_INT64 || typenum == NPY_UINT64 || type == NPY_LONG ) if( typenum == NPY_INT64 || typenum == NPY_UINT64 || type == NPY_LONG )
{ {
needcopy = needcast = true; needcopy = needcast = true;
new_typenum = NPY_INT32; new_typenum = NPY_INT;
type = CV_32S; type = CV_32S;
} }
else else
...@@ -442,7 +476,12 @@ static bool pyopencv_to(PyObject* obj, int& value, const char* name = "<unknown> ...@@ -442,7 +476,12 @@ static bool pyopencv_to(PyObject* obj, int& value, const char* name = "<unknown>
(void)name; (void)name;
if(!obj || obj == Py_None) if(!obj || obj == Py_None)
return true; return true;
value = (int)PyInt_AsLong(obj); if(PyInt_Check(obj))
value = (int)PyInt_AsLong(obj);
else if(PyLong_Check(obj))
value = (int)PyLong_AsLong(obj);
else
return false;
return value != -1 || !PyErr_Occurred(); return value != -1 || !PyErr_Occurred();
} }
...@@ -714,7 +753,14 @@ template<typename _Tp> struct pyopencvVecConverter ...@@ -714,7 +753,14 @@ template<typename _Tp> struct pyopencvVecConverter
PyObject* item_ij = items_i[j]; PyObject* item_ij = items_i[j];
if( PyInt_Check(item_ij)) if( PyInt_Check(item_ij))
{ {
int v = PyInt_AsLong(item_ij); int v = (int)PyInt_AsLong(item_ij);
if( v == -1 && PyErr_Occurred() )
break;
data[j] = saturate_cast<_Cp>(v);
}
else if( PyLong_Check(item_ij))
{
int v = (int)PyLong_AsLong(item_ij);
if( v == -1 && PyErr_Occurred() ) if( v == -1 && PyErr_Occurred() )
break; break;
data[j] = saturate_cast<_Cp>(v); data[j] = saturate_cast<_Cp>(v);
......
#/usr/bin/env python
import unittest
import random
import time
import math
import sys
import array
import urllib
import tarfile
import hashlib
import os
import getopt
import operator
import functools
import numpy as np
import cv2
import cv2.cv as cv
class NewOpenCVTests(unittest.TestCase):
def get_sample(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR):
if not filename in self.image_cache:
filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read()
self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
return self.image_cache[filename]
def setUp(self):
self.image_cache = {}
def hashimg(self, im):
""" Compute a hash for an image, useful for image comparisons """
return hashlib.md5(im.tostring()).digest()
# Tests to run first; check the handful of basic operations that the later tests rely on
class Hackathon244Tests(NewOpenCVTests):
def test_int_array(self):
a = np.array([-1, 2, -3, 4, -5])
absa0 = np.abs(a)
self.assert_(cv2.norm(a, cv2.NORM_L1) == 15)
absa1 = cv2.absdiff(a, 0)
self.assert_(cv2.norm(absa1, absa0, cv2.NORM_INF) == 0)
def test_imencode(self):
a = np.zeros((480, 640), dtype=np.uint8)
flag, ajpg = cv2.imencode("img_q90.jpg", a, [cv2.IMWRITE_JPEG_QUALITY, 90])
self.assert_(flag == True and ajpg.dtype == np.uint8 and ajpg.shape[0] > 1 and ajpg.shape[1] == 1)
if __name__ == '__main__':
print "testing", cv.__version__
random.seed(0)
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment