mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00
fixed building Python wrappers when Numpy is not available
This commit is contained in:
parent
37c1204d55
commit
8a8ba57b20
@ -1321,7 +1321,11 @@ message(STATUS "")
|
|||||||
message(STATUS " Interfaces: ")
|
message(STATUS " Interfaces: ")
|
||||||
message(STATUS " Python: ${BUILD_NEW_PYTHON_SUPPORT}")
|
message(STATUS " Python: ${BUILD_NEW_PYTHON_SUPPORT}")
|
||||||
message(STATUS " Python interpreter: ${PYTHON_EXECUTABLE}")
|
message(STATUS " Python interpreter: ${PYTHON_EXECUTABLE}")
|
||||||
message(STATUS " Python numpy: ${PYTHON_USE_NUMPY}")
|
if (PYTHON_USE_NUMPY)
|
||||||
|
message(STATUS " Python numpy: YES")
|
||||||
|
else()
|
||||||
|
message(STATUS " Python numpy: NO (Python interface will not cover OpenCV 2.x API)")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(IPP_FOUND AND USE_IPP)
|
if(IPP_FOUND AND USE_IPP)
|
||||||
message(STATUS " Use IPP: ${IPP_PATH}")
|
message(STATUS " Use IPP: ${IPP_PATH}")
|
||||||
|
@ -1400,8 +1400,8 @@ public:
|
|||||||
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
// todo read/write
|
// todo read/write
|
||||||
virtual void read( const FileNode& fn ) {}
|
virtual void read( const FileNode& ) {}
|
||||||
virtual void write( FileStorage& fs ) const {}
|
virtual void write( FileStorage& ) const {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ptr<FeatureDetector> detector;
|
Ptr<FeatureDetector> detector;
|
||||||
@ -1421,8 +1421,8 @@ public:
|
|||||||
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||||
|
|
||||||
// todo read/write
|
// todo read/write
|
||||||
virtual void read( const FileNode& fn ) {}
|
virtual void read( const FileNode& ) {}
|
||||||
virtual void write( FileStorage& fs ) const {}
|
virtual void write( FileStorage& ) const {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ptr<FeatureDetector> detector;
|
Ptr<FeatureDetector> detector;
|
||||||
|
@ -1860,7 +1860,7 @@ static int convert_to_floats(PyObject *o, floats *dst, const char *name = "no_na
|
|||||||
} else if (PyNumber_Check(o)) {
|
} else if (PyNumber_Check(o)) {
|
||||||
dst->count = 1;
|
dst->count = 1;
|
||||||
dst->f = new float[1];
|
dst->f = new float[1];
|
||||||
dst->f[0] = PyFloat_AsDouble(o);
|
dst->f[0] = (float)PyFloat_AsDouble(o);
|
||||||
} else {
|
} else {
|
||||||
return failmsg("Expected list of floats, or float for argument '%s'", name);
|
return failmsg("Expected list of floats, or float for argument '%s'", name);
|
||||||
}
|
}
|
||||||
@ -3847,9 +3847,11 @@ static int zero = 0;
|
|||||||
|
|
||||||
#include "generated0.i"
|
#include "generated0.i"
|
||||||
|
|
||||||
|
#if PYTHON_USE_NUMPY
|
||||||
#include "opencv2x.h"
|
#include "opencv2x.h"
|
||||||
#include "pyopencv_generated_types.h"
|
#include "pyopencv_generated_types.h"
|
||||||
#include "pyopencv_generated_funcs.h"
|
#include "pyopencv_generated_funcs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyMethodDef methods[] = {
|
static PyMethodDef methods[] = {
|
||||||
|
|
||||||
@ -3865,7 +3867,10 @@ static PyMethodDef methods[] = {
|
|||||||
{"temp_test", temp_test, METH_VARARGS},
|
{"temp_test", temp_test, METH_VARARGS},
|
||||||
|
|
||||||
#include "generated1.i"
|
#include "generated1.i"
|
||||||
|
|
||||||
|
#if PYTHON_USE_NUMPY
|
||||||
#include "pyopencv_generated_func_tab.h"
|
#include "pyopencv_generated_func_tab.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
@ -3918,7 +3923,10 @@ void initcv()
|
|||||||
MKTYPE(memtrack);
|
MKTYPE(memtrack);
|
||||||
|
|
||||||
#include "generated4.i"
|
#include "generated4.i"
|
||||||
|
|
||||||
|
#if PYTHON_USE_NUMPY
|
||||||
#include "pyopencv_generated_type_reg.h"
|
#include "pyopencv_generated_type_reg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
m = Py_InitModule(MODULESTR"", methods);
|
m = Py_InitModule(MODULESTR"", methods);
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
@ -4015,7 +4023,10 @@ void initcv()
|
|||||||
PUBLISH(GC_EVAL);
|
PUBLISH(GC_EVAL);
|
||||||
|
|
||||||
#include "generated2.i"
|
#include "generated2.i"
|
||||||
|
|
||||||
|
#if PYTHON_USE_NUMPY
|
||||||
#include "pyopencv_generated_const_reg.h"
|
#include "pyopencv_generated_const_reg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ static PyObject* pyopencv_from(const ${cname}& r)
|
|||||||
|
|
||||||
static bool pyopencv_to(PyObject* src, ${cname}& dst, const char* name="<unknown>")
|
static bool pyopencv_to(PyObject* src, ${cname}& dst, const char* name="<unknown>")
|
||||||
{
|
{
|
||||||
if( src == NULL or src == Py_None )
|
if( src == NULL || src == Py_None )
|
||||||
return true;
|
return true;
|
||||||
if(!PyObject_TypeCheck(src, &pyopencv_${name}_Type))
|
if(!PyObject_TypeCheck(src, &pyopencv_${name}_Type))
|
||||||
{
|
{
|
||||||
|
@ -693,4 +693,11 @@ static inline PyObject* pyopencv_from(const Moments& m)
|
|||||||
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "mu03", m.nu03);
|
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "mu03", m.nu03);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline PyObject* pyopencv_from(const CvDTreeNode* node)
|
||||||
|
{
|
||||||
|
double value = node->value;
|
||||||
|
int ivalue = cvRound(value);
|
||||||
|
return value == ivalue ? PyInt_FromLong(ivalue) : PyFloat_FromDouble(value);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user