moved Python bindings source code into src subdirectory; preparing to add python/doc and python/test subdirectories

pull/13383/head
Vadim Pisarevsky 14 years ago
parent 26d348a5b7
commit 335370a7c0
  1. 24
      modules/python/CMakeLists.txt
  2. BIN
      modules/python/hdr_parser.pyc
  3. 0
      modules/python/src/api
  4. 4
      modules/python/src/cv.cpp
  5. 0
      modules/python/src/defs
  6. 0
      modules/python/src/gen.py
  7. 0
      modules/python/src/gen2.py
  8. 36
      modules/python/src/hdr_parser.py
  9. BIN
      modules/python/src/hdr_parser.pyc
  10. 0
      modules/python/src/opencv2x.h
  11. 0
      modules/python/src/opencv_extra_api.hpp

@ -5,7 +5,7 @@ project(opencv_python)
include_directories(${PYTHON_INCLUDE_PATH}) include_directories(${PYTHON_INCLUDE_PATH})
include_directories( include_directories(
${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/modules/core/include" "${CMAKE_SOURCE_DIR}/modules/core/include"
"${CMAKE_SOURCE_DIR}/modules/imgproc/include" "${CMAKE_SOURCE_DIR}/modules/imgproc/include"
"${CMAKE_SOURCE_DIR}/modules/video/include" "${CMAKE_SOURCE_DIR}/modules/video/include"
@ -30,7 +30,7 @@ set(opencv_hdrs "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/core.hpp"
"${CMAKE_SOURCE_DIR}/modules/features2d/include/opencv2/features2d/features2d.hpp" "${CMAKE_SOURCE_DIR}/modules/features2d/include/opencv2/features2d/features2d.hpp"
"${CMAKE_SOURCE_DIR}/modules/calib3d/include/opencv2/calib3d/calib3d.hpp" "${CMAKE_SOURCE_DIR}/modules/calib3d/include/opencv2/calib3d/calib3d.hpp"
"${CMAKE_SOURCE_DIR}/modules/objdetect/include/opencv2/objdetect/objdetect.hpp" "${CMAKE_SOURCE_DIR}/modules/objdetect/include/opencv2/objdetect/objdetect.hpp"
"${CMAKE_SOURCE_DIR}/modules/python/opencv_extra_api.hpp") "${CMAKE_SOURCE_DIR}/modules/python/src/opencv_extra_api.hpp")
set(generated_hdrs set(generated_hdrs
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h" "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h"
@ -43,27 +43,27 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
endif() endif()
file(GLOB lib_srcs "*.cpp") file(GLOB lib_srcs "src/*.cpp")
file(GLOB lib_hdrs "*.h") file(GLOB lib_hdrs "src/*.h")
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated0.i OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated0.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen.py ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src/gen.py" "${CMAKE_CURRENT_SOURCE_DIR}/src"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/api DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/api
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/defs DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/defs
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/gen.py
) )
add_custom_command( add_custom_command(
OUTPUT ${generated_hdrs} OUTPUT ${generated_hdrs}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen2.py ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen2.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/gen2.py
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hdr_parser.py DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/hdr_parser.py
DEPENDS ${opencv_hdrs} DEPENDS ${opencv_hdrs}
) )
set(the_target "opencv_python") set(the_target "opencv_python")
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${CMAKE_CURRENT_BINARY_DIR}/generated0.i opencv2x.h opencv_extra_api.hpp ${generated_hdrs}) add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${CMAKE_CURRENT_BINARY_DIR}/generated0.i src/opencv2x.h src/opencv_extra_api.hpp ${generated_hdrs})
target_link_libraries(${the_target} ${PYTHON_LIBRARIES} opencv_core opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_objdetect opencv_legacy opencv_contrib) target_link_libraries(${the_target} ${PYTHON_LIBRARIES} opencv_core opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_objdetect opencv_legacy opencv_contrib)
set_target_properties(${the_target} PROPERTIES PREFIX "") set_target_properties(${the_target} PROPERTIES PREFIX "")

Binary file not shown.

@ -3946,7 +3946,7 @@ static double cppKMeans(const CvArr* _samples, int cluster_count, CvArr* _labels
(labels.cols == 1 || labels.rows == 1) && (labels.cols == 1 || labels.rows == 1) &&
labels.cols + labels.rows - 1 == data.rows ); labels.cols + labels.rows - 1 == data.rows );
return cv::kmeans(data, cluster_count, labels, termcrit, attempts, return cv::kmeans(data, cluster_count, labels, termcrit, attempts,
flags, _centers ? &centers : 0 ); flags, _centers ? cv::OutputArray(centers) : cv::OutputArray() );
} }
#define cvKMeans2(samples, nclusters, labels, termcrit, attempts, flags, centers) \ #define cvKMeans2(samples, nclusters, labels, termcrit, attempts, flags, centers) \
@ -4038,7 +4038,7 @@ void initcv()
m = Py_InitModule(MODULESTR"", methods); m = Py_InitModule(MODULESTR"", methods);
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
PyDict_SetItemString(d, "__version__", PyString_FromString("$Rev$")); PyDict_SetItemString(d, "__version__", PyString_FromString("$Rev: 4557 $"));
opencv_error = PyErr_NewException((char*)MODULESTR".error", NULL, NULL); opencv_error = PyErr_NewException((char*)MODULESTR".error", NULL, NULL);
PyDict_SetItemString(d, "error", opencv_error); PyDict_SetItemString(d, "error", opencv_error);

@ -2,15 +2,15 @@ import os, sys, re
# the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt # the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt
opencv_hdr_list = [ opencv_hdr_list = [
"../core/include/opencv2/core/core.hpp", "../../core/include/opencv2/core/core.hpp",
"../ml/include/opencv2/ml/ml.hpp", "../../ml/include/opencv2/ml/ml.hpp",
"../imgproc/include/opencv2/imgproc/imgproc.hpp", "../../imgproc/include/opencv2/imgproc/imgproc.hpp",
"../calib3d/include/opencv2/calib3d/calib3d.hpp", "../../calib3d/include/opencv2/calib3d/calib3d.hpp",
"../features2d/include/opencv2/features2d/features2d.hpp", "../../features2d/include/opencv2/features2d/features2d.hpp",
"../video/include/opencv2/video/tracking.hpp", "../../video/include/opencv2/video/tracking.hpp",
"../video/include/opencv2/video/background_segm.hpp", "../../video/include/opencv2/video/background_segm.hpp",
"../objdetect/include/opencv2/objdetect/objdetect.hpp", "../../objdetect/include/opencv2/objdetect/objdetect.hpp",
"../highgui/include/opencv2/highgui/highgui.hpp", "../../highgui/include/opencv2/highgui/highgui.hpp",
"opencv_extra_api.hpp", "opencv_extra_api.hpp",
] ]
@ -192,7 +192,7 @@ class CppHeaderParser(object):
arg_type += "*" arg_type += "*"
arg_type = self.batch_replace(arg_type, [("std::", ""), ("cv::", "")]) arg_type = self.batch_replace(arg_type, [("std::", ""), ("cv::", "")])
return arg_type, arg_name, modlist, argno return arg_type, arg_name, modlist, argno
def parse_enum(self, decl_str): def parse_enum(self, decl_str):
@ -375,6 +375,22 @@ class CppHeaderParser(object):
if eqpos >= 0: if eqpos >= 0:
a = a[:eqpos].strip() a = a[:eqpos].strip()
arg_type, arg_name, modlist, argno = self.parse_arg(a, argno) arg_type, arg_name, modlist, argno = self.parse_arg(a, argno)
if arg_type == "InputArray" or arg_type == "InputOutputArray":
arg_type = "Mat"
elif arg_type == "OutputArray":
arg_type = "Mat"
modlist.append("/O")
elif arg_type == "InputArrayOfArrays" or arg_type == "InputOutputArrayOfArrays":
arg_type = "vector_Mat"
elif arg_type == "OutputArrayOfArrays":
arg_type = "vector_Mat"
modlist.append("/O")
defval = self.batch_replace(defval, [("InputArrayOfArrays", "vector<Mat>"),
("InputOutputArrayOfArrays", "vector<Mat>"),
("OutputArrayOfArrays", "vector<Mat>"),
("InputArray", "Mat"),
("InputOutputArray", "Mat"),
("OutputArray", "Mat")]).strip()
args.append([arg_type, arg_name, defval, modlist]) args.append([arg_type, arg_name, defval, modlist])
npos = arg_start-1 npos = arg_start-1

Binary file not shown.
Loading…
Cancel
Save