Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
569b1ad5
Commit
569b1ad5
authored
Jul 12, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
embeded cv Python module into cv2.
parent
9b464199
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
139 additions
and
97 deletions
+139
-97
CMakeLists.txt
CMakeLists.txt
+1
-1
CMakeLists.txt
modules/CMakeLists.txt
+1
-1
old_basic_structures.rst
modules/core/doc/old_basic_structures.rst
+1
-1
CMakeLists.txt
modules/python/CMakeLists.txt
+24
-44
api
modules/python/src2/api
+0
-0
cv2.cpp
modules/python/src2/cv2.cpp
+6
-4
cv2.cv.hpp
modules/python/src2/cv2.cv.hpp
+0
-0
defs
modules/python/src2/defs
+0
-0
gen.py
modules/python/src2/gen.py
+0
-0
calchist.py
modules/python/test/calchist.py
+1
-1
camera_calibration.py
modules/python/test/camera_calibration.py
+1
-1
findstereocorrespondence.py
modules/python/test/findstereocorrespondence.py
+1
-1
goodfeatures.py
modules/python/test/goodfeatures.py
+1
-1
leak1.py
modules/python/test/leak1.py
+1
-1
leak2.py
modules/python/test/leak2.py
+1
-1
leak3.py
modules/python/test/leak3.py
+1
-1
leak4.py
modules/python/test/leak4.py
+1
-1
precornerdetect.py
modules/python/test/precornerdetect.py
+1
-1
test.py
modules/python/test/test.py
+1
-1
ticket_6.py
modules/python/test/ticket_6.py
+1
-1
tickets.py
modules/python/test/tickets.py
+1
-1
test_main.cpp
modules/video/test/test_main.cpp
+61
-1
camera.py
samples/python/camera.py
+1
-1
camshift.py
samples/python/camshift.py
+1
-1
chessboard.py
samples/python/chessboard.py
+1
-1
contours.py
samples/python/contours.py
+1
-1
convexhull.py
samples/python/convexhull.py
+1
-1
cv20squares.py
samples/python/cv20squares.py
+1
-1
cvutils.py
samples/python/cvutils.py
+1
-1
delaunay.py
samples/python/delaunay.py
+1
-1
demhist.py
samples/python/demhist.py
+1
-1
dft.py
samples/python/dft.py
+1
-1
distrans.py
samples/python/distrans.py
+1
-1
dmtx.py
samples/python/dmtx.py
+1
-1
drawing.py
samples/python/drawing.py
+1
-1
edge.py
samples/python/edge.py
+1
-1
facedetect.py
samples/python/facedetect.py
+1
-1
ffilldemo.py
samples/python/ffilldemo.py
+1
-1
fitellipse.py
samples/python/fitellipse.py
+1
-1
houghlines.py
samples/python/houghlines.py
+1
-1
inpaint.py
samples/python/inpaint.py
+1
-1
kalman.py
samples/python/kalman.py
+1
-1
kmeans.py
samples/python/kmeans.py
+1
-1
laplace.py
samples/python/laplace.py
+1
-1
lkdemo.py
samples/python/lkdemo.py
+1
-1
logpolar.py
samples/python/logpolar.py
+1
-1
minarea.py
samples/python/minarea.py
+1
-1
minidemo.py
samples/python/minidemo.py
+1
-1
morphology.py
samples/python/morphology.py
+1
-1
motempl.py
samples/python/motempl.py
+1
-1
numpy_array.py
samples/python/numpy_array.py
+1
-1
numpy_warhol.py
samples/python/numpy_warhol.py
+1
-1
pyramid_segmentation.py
samples/python/pyramid_segmentation.py
+1
-1
squares.py
samples/python/squares.py
+1
-1
watershed.py
samples/python/watershed.py
+1
-1
No files found.
CMakeLists.txt
View file @
569b1ad5
...
@@ -1611,7 +1611,7 @@ status("")
...
@@ -1611,7 +1611,7 @@ status("")
status
(
" Interfaces:"
)
status
(
" Interfaces:"
)
status
(
" Python:"
BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE NO
)
status
(
" Python:"
BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE NO
)
status
(
" Python interpreter:"
PYTHON_EXECUTABLE THEN
"
${
PYTHON_EXECUTABLE
}
(ver
${
PYTHON_VERSION_MAJOR_MINOR
}
)"
ELSE NO
)
status
(
" Python interpreter:"
PYTHON_EXECUTABLE THEN
"
${
PYTHON_EXECUTABLE
}
(ver
${
PYTHON_VERSION_MAJOR_MINOR
}
)"
ELSE NO
)
status
(
" Python numpy:"
PYTHON_USE_NUMPY THEN YES ELSE
"NO (Python
interface will not cover OpenCV 2.x API
)"
)
status
(
" Python numpy:"
PYTHON_USE_NUMPY THEN YES ELSE
"NO (Python
wrappers will not be generated
)"
)
if
(
ANDROID AND ANDROID_API_LEVEL LESS 8
)
if
(
ANDROID AND ANDROID_API_LEVEL LESS 8
)
status
(
" Java:"
"NO (Java API requires Android API level 8 or higher)"
)
status
(
" Java:"
"NO (Java API requires Android API level 8 or higher)"
)
else
()
else
()
...
...
modules/CMakeLists.txt
View file @
569b1ad5
...
@@ -24,7 +24,7 @@ add_subdirectory(contrib)
...
@@ -24,7 +24,7 @@ add_subdirectory(contrib)
add_subdirectory
(
ml
)
add_subdirectory
(
ml
)
add_subdirectory
(
objdetect
)
add_subdirectory
(
objdetect
)
if
(
PYTHONLIBS_FOUND AND BUILD_NEW_PYTHON_SUPPORT
)
if
(
PYTHONLIBS_FOUND AND BUILD_NEW_PYTHON_SUPPORT
AND PYTHON_USE_NUMPY
)
add_subdirectory
(
python
)
add_subdirectory
(
python
)
endif
()
endif
()
...
...
modules/core/doc/old_basic_structures.rst
View file @
569b1ad5
...
@@ -1729,7 +1729,7 @@ For example, `NumPy <http://numpy.scipy.org/>`_ arrays support the array interfa
...
@@ -1729,7 +1729,7 @@ For example, `NumPy <http://numpy.scipy.org/>`_ arrays support the array interfa
.. code-block::python
.. code-block::python
>>> import cv, numpy
>>> import cv
2.cv as cv
, numpy
>>> a = numpy.ones((480, 640))
>>> a = numpy.ones((480, 640))
>>> mat = cv.fromarray(a)
>>> mat = cv.fromarray(a)
>>> print cv.GetDims(mat), cv.CV_MAT_CN(cv.GetElemType(mat))
>>> print cv.GetDims(mat), cv.CV_MAT_CN(cv.GetElemType(mat))
...
...
modules/python/CMakeLists.txt
View file @
569b1ad5
...
@@ -5,7 +5,6 @@ project(opencv_python)
...
@@ -5,7 +5,6 @@ project(opencv_python)
include_directories
(
${
PYTHON_INCLUDE_PATH
}
)
include_directories
(
${
PYTHON_INCLUDE_PATH
}
)
include_directories
(
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2"
"
${
OpenCV_SOURCE_DIR
}
/modules/core/include"
"
${
OpenCV_SOURCE_DIR
}
/modules/core/include"
"
${
OpenCV_SOURCE_DIR
}
/modules/imgproc/include"
"
${
OpenCV_SOURCE_DIR
}
/modules/imgproc/include"
...
@@ -37,37 +36,6 @@ if(MSVC)
...
@@ -37,37 +36,6 @@ if(MSVC)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/W3"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/W3"
)
endif
()
endif
()
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1/gen.py"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1"
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1/api
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1/defs
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src1/gen.py
)
set
(
cv_target
"opencv_python"
)
add_library
(
${
cv_target
}
SHARED src1/cv.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i
)
target_link_libraries
(
${
cv_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
(
${
cv_target
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
cv_target
}
PROPERTIES OUTPUT_NAME
"cv"
)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
-c
"import distutils.sysconfig; print distutils.sysconfig.get_config_var('SO')"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
OUTPUT_VARIABLE CVPY_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set_target_properties
(
${
cv_target
}
PROPERTIES SUFFIX
${
CVPY_SUFFIX
}
)
if
(
MSVC AND NOT BUILD_SHARED_LIBS
)
set_target_properties
(
${
cv_target
}
PROPERTIES LINK_FLAGS
"/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG"
)
endif
()
set
(
cvpymodules
${
cv_target
}
)
if
(
PYTHON_USE_NUMPY
)
set
(
cv2_generated_hdrs
set
(
cv2_generated_hdrs
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_funcs.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_funcs.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_func_tab.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_func_tab.h"
...
@@ -75,28 +43,41 @@ set(cv2_generated_hdrs
...
@@ -75,28 +43,41 @@ set(cv2_generated_hdrs
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_type_reg.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_type_reg.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_const_reg.h"
)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_const_reg.h"
)
add_custom_command
(
add_custom_command
(
OUTPUT
${
cv2_generated_hdrs
}
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen2.py"
${
CMAKE_CURRENT_BINARY_DIR
}
${
opencv_hdrs
}
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen.py"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2"
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen2.py
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/api
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/hdr_parser.py
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/defs
DEPENDS
${
opencv_hdrs
}
)
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen.py
)
set
(
cv2_target
"opencv2_python"
)
add_custom_command
(
add_library
(
${
cv2_target
}
SHARED src2/cv2.cpp src2/opencv_extra_api.hpp
${
cv2_generated_hdrs
}
)
OUTPUT
${
cv2_generated_hdrs
}
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen2.py"
${
CMAKE_CURRENT_BINARY_DIR
}
${
opencv_hdrs
}
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/gen2.py
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/src2/hdr_parser.py
DEPENDS
${
opencv_hdrs
}
)
set
(
cv2_target
"opencv_python"
)
add_library
(
${
cv2_target
}
SHARED src2/cv2.cpp
${
CMAKE_CURRENT_BINARY_DIR
}
/generated0.i src2/opencv_extra_api.hpp
${
cv2_generated_hdrs
}
src2/cv2.cv.hpp
)
target_link_libraries
(
${
cv2_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
(
${
cv2_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
(
${
cv2_target
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
cv2_target
}
PROPERTIES PREFIX
""
)
set_target_properties
(
${
cv2_target
}
PROPERTIES OUTPUT_NAME
"cv2"
)
set_target_properties
(
${
cv2_target
}
PROPERTIES OUTPUT_NAME
"cv2"
)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
-c
"import distutils.sysconfig; print distutils.sysconfig.get_config_var('SO')"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
OUTPUT_VARIABLE CVPY_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set_target_properties
(
${
cv2_target
}
PROPERTIES SUFFIX
${
CVPY_SUFFIX
}
)
set_target_properties
(
${
cv2_target
}
PROPERTIES SUFFIX
${
CVPY_SUFFIX
}
)
if
(
MSVC AND NOT BUILD_SHARED_LIBS
)
if
(
MSVC AND NOT BUILD_SHARED_LIBS
)
set_target_properties
(
${
cv2_target
}
PROPERTIES LINK_FLAGS
"/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG"
)
set_target_properties
(
${
cv2_target
}
PROPERTIES LINK_FLAGS
"/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG"
)
endif
()
endif
()
set
(
cvpymodules
${
cvpymodules
}
${
cv2_target
}
)
set
(
cvpymodules
${
cv2_target
}
)
endif
()
if
(
WIN32
)
if
(
WIN32
)
install
(
TARGETS
${
cvpymodules
}
install
(
TARGETS
${
cvpymodules
}
...
@@ -105,7 +86,6 @@ if(WIN32)
...
@@ -105,7 +86,6 @@ if(WIN32)
ARCHIVE DESTINATION
"Python
${
PYTHON_VERSION_MAJOR_MINOR
}
/Lib/site-packages"
COMPONENT main
ARCHIVE DESTINATION
"Python
${
PYTHON_VERSION_MAJOR_MINOR
}
/Lib/site-packages"
COMPONENT main
)
)
else
()
else
()
#install(FILES ${LIBRARY_OUTPUT_PATH}/cv${CVPY_SUFFIX} DESTINATION ${PYTHON_PACKAGES_PATH})
install
(
TARGETS
${
cvpymodules
}
install
(
TARGETS
${
cvpymodules
}
RUNTIME DESTINATION
${
PYTHON_PACKAGES_PATH
}
COMPONENT main
RUNTIME DESTINATION
${
PYTHON_PACKAGES_PATH
}
COMPONENT main
LIBRARY DESTINATION
${
PYTHON_PACKAGES_PATH
}
COMPONENT main
LIBRARY DESTINATION
${
PYTHON_PACKAGES_PATH
}
COMPONENT main
...
...
modules/python/src
1
/api
→
modules/python/src
2
/api
View file @
569b1ad5
File moved
modules/python/src2/cv2.cpp
View file @
569b1ad5
...
@@ -833,6 +833,8 @@ static int to_ok(PyTypeObject *to)
...
@@ -833,6 +833,8 @@ static int to_ok(PyTypeObject *to)
return
(
PyType_Ready
(
to
)
==
0
);
return
(
PyType_Ready
(
to
)
==
0
);
}
}
#include "cv2.cv.hpp"
extern
"C"
extern
"C"
#if defined WIN32 || defined _WIN32
#if defined WIN32 || defined _WIN32
__declspec
(
dllexport
)
__declspec
(
dllexport
)
...
@@ -848,16 +850,17 @@ void initcv2()
...
@@ -848,16 +850,17 @@ void initcv2()
#include "pyopencv_generated_type_reg.h"
#include "pyopencv_generated_type_reg.h"
#endif
#endif
PyObject
*
m
=
Py_InitModule
(
MODULESTR
""
,
methods
);
PyObject
*
m
=
Py_InitModule
(
MODULESTR
,
methods
);
PyObject
*
d
=
PyModule_GetDict
(
m
);
PyObject
*
d
=
PyModule_GetDict
(
m
);
PyDict_SetItemString
(
d
,
"__version__"
,
PyString_FromString
(
"$Rev: 4557 $"
));
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
);
PyObject
*
cv_m
=
init_cv
();
// AFAIK the only floating-point constant
PyDict_SetItemString
(
d
,
"cv"
,
cv_m
);
PyDict_SetItemString
(
d
,
"CV_PI"
,
PyFloat_FromDouble
(
CV_PI
));
#define PUBLISH(I) PyDict_SetItemString(d, #I, PyInt_FromLong(I))
#define PUBLISH(I) PyDict_SetItemString(d, #I, PyInt_FromLong(I))
#define PUBLISHU(I) PyDict_SetItemString(d, #I, PyLong_FromUnsignedLong(I))
#define PUBLISHU(I) PyDict_SetItemString(d, #I, PyLong_FromUnsignedLong(I))
...
@@ -942,7 +945,6 @@ void initcv2()
...
@@ -942,7 +945,6 @@ void initcv2()
PUBLISH
(
CV_AA
);
PUBLISH
(
CV_AA
);
#include "pyopencv_generated_const_reg.h"
#include "pyopencv_generated_const_reg.h"
}
}
modules/python/src
1/cv.c
pp
→
modules/python/src
2/cv2.cv.h
pp
View file @
569b1ad5
This diff is collapsed.
Click to expand it.
modules/python/src
1
/defs
→
modules/python/src
2
/defs
View file @
569b1ad5
File moved
modules/python/src
1
/gen.py
→
modules/python/src
2
/gen.py
View file @
569b1ad5
File moved
modules/python/test/calchist.py
View file @
569b1ad5
# Calculating and displaying 2D Hue-Saturation histogram of a color image
# Calculating and displaying 2D Hue-Saturation histogram of a color image
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
def
hs_histogram
(
src
):
def
hs_histogram
(
src
):
# Convert to HSV
# Convert to HSV
...
...
modules/python/test/camera_calibration.py
View file @
569b1ad5
...
@@ -5,7 +5,7 @@ import random
...
@@ -5,7 +5,7 @@ import random
import
numpy
import
numpy
import
transformations
import
transformations
import
cv
import
cv
2.cv
as
cv
def
clamp
(
a
,
x
,
b
):
def
clamp
(
a
,
x
,
b
):
return
numpy
.
maximum
(
a
,
numpy
.
minimum
(
x
,
b
))
return
numpy
.
maximum
(
a
,
numpy
.
minimum
(
x
,
b
))
...
...
modules/python/test/findstereocorrespondence.py
View file @
569b1ad5
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
def
findstereocorrespondence
(
image_left
,
image_right
):
def
findstereocorrespondence
(
image_left
,
image_right
):
# image_left and image_right are the input 8-bit single-channel images
# image_left and image_right are the input 8-bit single-channel images
...
...
modules/python/test/goodfeatures.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
unittest
import
unittest
class
TestGoodFeaturesToTrack
(
unittest
.
TestCase
):
class
TestGoodFeaturesToTrack
(
unittest
.
TestCase
):
...
...
modules/python/test/leak1.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
numpy
as
np
import
numpy
as
np
cv
.
NamedWindow
(
'Leak'
)
cv
.
NamedWindow
(
'Leak'
)
while
1
:
while
1
:
...
...
modules/python/test/leak2.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
numpy
as
np
import
numpy
as
np
import
time
import
time
...
...
modules/python/test/leak3.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
math
import
math
import
time
import
time
...
...
modules/python/test/leak4.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
math
import
math
import
time
import
time
...
...
modules/python/test/precornerdetect.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
def
precornerdetect
(
image
):
def
precornerdetect
(
image
):
# assume that the image is floating-point
# assume that the image is floating-point
...
...
modules/python/test/test.py
View file @
569b1ad5
...
@@ -12,7 +12,7 @@ import getopt
...
@@ -12,7 +12,7 @@ import getopt
import
operator
import
operator
import
functools
import
functools
import
cv
import
cv
2.cv
as
cv
class
OpenCVTests
(
unittest
.
TestCase
):
class
OpenCVTests
(
unittest
.
TestCase
):
...
...
modules/python/test/ticket_6.py
View file @
569b1ad5
import
urllib
import
urllib
import
cv
import
cv
2.cv
as
cv
import
Image
import
Image
import
unittest
import
unittest
...
...
modules/python/test/tickets.py
View file @
569b1ad5
...
@@ -6,7 +6,7 @@ import sys
...
@@ -6,7 +6,7 @@ import sys
import
array
import
array
import
os
import
os
import
cv
import
cv
2.cv
as
cv
def
find_sample
(
s
):
def
find_sample
(
s
):
for
d
in
[
"../samples/c/"
,
"../doc/pics/"
]:
for
d
in
[
"../samples/c/"
,
"../doc/pics/"
]:
...
...
modules/video/test/test_main.cpp
View file @
569b1ad5
#include "test_precomp.hpp"
#include "test_precomp.hpp"
CV_TEST_MAIN
(
"cv"
)
//CV_TEST_MAIN("cv")
#if 1
using
namespace
cv
;
int
main
(
int
,
char
**
)
{
Mat
prevImg
=
imread
(
"/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_1.bmp"
,
0
);
Mat
nextImg
=
imread
(
"/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/rock_2.bmp"
,
0
);
FileStorage
fs
(
"/Users/vp/work/ocv/opencv_extra/testdata/cv/optflow/lk_prev.dat"
,
FileStorage
::
READ
);
vector
<
Point2f
>
u
,
v
;
Mat
_u
;
fs
[
"points"
]
>>
_u
;
_u
.
reshape
(
2
,
0
).
copyTo
(
u
);
vector
<
uchar
>
status
;
vector
<
float
>
err
;
double
tmin
=
0
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
double
t
=
(
double
)
getTickCount
();
#if 1
calcOpticalFlowPyrLK
(
prevImg
,
nextImg
,
u
,
v
,
status
,
err
,
Size
(
11
,
11
),
5
,
TermCriteria
(
TermCriteria
::
MAX_ITER
+
TermCriteria
::
EPS
,
30
,
0.01
),
100
);
#else
{
CvMat
_prevImg
=
prevImg
;
CvMat
_nextImg
=
nextImg
;
v
.
resize
(
u
.
size
());
status
.
resize
(
u
.
size
());
err
.
resize
(
u
.
size
());
cvCalcOpticalFlowPyrLK
(
&
_prevImg
,
&
_nextImg
,
0
,
0
,
(
CvPoint2D32f
*
)
&
u
[
0
],
(
CvPoint2D32f
*
)
&
v
[
0
],
(
int
)
u
.
size
(),
cvSize
(
21
,
21
),
4
,
(
char
*
)
&
status
[
0
],
&
err
[
0
],
cvTermCriteria
(
CV_TERMCRIT_EPS
+
CV_TERMCRIT_ITER
,
30
,
0.01
),
0
);
}
#endif
t
=
(
double
)
getTickCount
()
-
t
;
tmin
=
k
==
0
?
t
:
std
::
min
(
tmin
,
t
);
}
printf
(
"time = %gms
\n
"
,
tmin
*
1000.
/
getTickFrequency
());
Mat
color
;
cvtColor
(
prevImg
,
color
,
CV_GRAY2BGR
);
for
(
size_t
i
=
0
;
i
<
u
.
size
();
i
++
)
{
Point2f
ui
=
u
[
i
],
vi
=
v
[
i
];
if
(
cvIsNaN
(
v
[
i
].
x
)
||
cvIsNaN
(
v
[
i
].
y
)
||
!
status
[
i
]
)
{
const
float
r
=
2.
f
;
line
(
color
,
Point2f
(
u
[
i
].
x
-
r
,
u
[
i
].
y
-
r
),
Point2f
(
u
[
i
].
x
+
r
,
u
[
i
].
y
+
r
),
Scalar
(
0
,
0
,
255
),
1
);
line
(
color
,
Point2f
(
u
[
i
].
x
-
r
,
u
[
i
].
y
+
r
),
Point2f
(
u
[
i
].
x
+
r
,
u
[
i
].
y
-
r
),
Scalar
(
0
,
0
,
255
),
1
);
continue
;
}
line
(
color
,
ui
,
vi
,
Scalar
(
0
,
255
,
0
),
1
);
}
imshow
(
"flow"
,
color
);
waitKey
();
return
0
;
}
#endif
samples/python/camera.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
time
import
time
cv
.
NamedWindow
(
"camera"
,
1
)
cv
.
NamedWindow
(
"camera"
,
1
)
...
...
samples/python/camshift.py
View file @
569b1ad5
#!/usr/bin/env python
#!/usr/bin/env python
import
cv
import
cv
2.cv
as
cv
def
is_rect_nonzero
(
r
):
def
is_rect_nonzero
(
r
):
(
_
,
_
,
w
,
h
)
=
r
(
_
,
_
,
w
,
h
)
=
r
...
...
samples/python/chessboard.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
cv
import
cv
2.cv
as
cv
import
sys
import
sys
import
urllib2
import
urllib2
...
...
samples/python/contours.py
View file @
569b1ad5
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
print
"OpenCV Python version of contours"
print
"OpenCV Python version of contours"
# import the necessary things for OpenCV
# import the necessary things for OpenCV
import
cv
import
cv
2.cv
as
cv
# some default constants
# some default constants
_SIZE
=
500
_SIZE
=
500
...
...
samples/python/convexhull.py
View file @
569b1ad5
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
print
"OpenCV Python version of convexhull"
print
"OpenCV Python version of convexhull"
# import the necessary things for OpenCV
# import the necessary things for OpenCV
import
cv
import
cv
2.cv
as
cv
# to generate random values
# to generate random values
import
random
import
random
...
...
samples/python/cv20squares.py
View file @
569b1ad5
...
@@ -5,7 +5,7 @@ Find Squares in image by finding countours and filtering
...
@@ -5,7 +5,7 @@ Find Squares in image by finding countours and filtering
#otherwise ok
#otherwise ok
import
math
import
math
import
cv
import
cv
2.cv
as
cv
def
angle
(
pt1
,
pt2
,
pt0
):
def
angle
(
pt1
,
pt2
,
pt0
):
"calculate angle contained by 3 points(x, y)"
"calculate angle contained by 3 points(x, y)"
...
...
samples/python/cvutils.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
urllib2
import
urllib2
from
sys
import
argv
from
sys
import
argv
...
...
samples/python/delaunay.py
View file @
569b1ad5
...
@@ -6,7 +6,7 @@ delaunay triangulation and voronoi tesselation
...
@@ -6,7 +6,7 @@ delaunay triangulation and voronoi tesselation
Original Author (C version): ?
Original Author (C version): ?
Converted to Python by: Roman Stanchak
Converted to Python by: Roman Stanchak
"""
"""
import
cv
import
cv
2.cv
as
cv
import
random
import
random
def
draw_subdiv_point
(
img
,
fp
,
color
):
def
draw_subdiv_point
(
img
,
fp
,
color
):
...
...
samples/python/demhist.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
cv
import
cv
2.cv
as
cv
import
sys
import
sys
import
urllib2
import
urllib2
...
...
samples/python/dft.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
cv
import
cv
2.cv
as
cv
import
sys
import
sys
import
urllib2
import
urllib2
...
...
samples/python/distrans.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
import
urllib2
import
urllib2
wndname
=
"Distance transform"
wndname
=
"Distance transform"
...
...
samples/python/dmtx.py
View file @
569b1ad5
import
cv
import
cv
2.cv
as
cv
import
time
import
time
from
pydmtx
import
DataMatrix
from
pydmtx
import
DataMatrix
import
numpy
import
numpy
...
...
samples/python/drawing.py
View file @
569b1ad5
...
@@ -4,7 +4,7 @@ import colorsys
...
@@ -4,7 +4,7 @@ import colorsys
print
"OpenCV Python version of drawing"
print
"OpenCV Python version of drawing"
import
cv
import
cv
2.cv
as
cv
def
random_color
(
random
):
def
random_color
(
random
):
"""
"""
...
...
samples/python/edge.py
View file @
569b1ad5
...
@@ -4,7 +4,7 @@ print "OpenCV Python version of edge"
...
@@ -4,7 +4,7 @@ print "OpenCV Python version of edge"
import
sys
import
sys
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
# some definitions
# some definitions
win_name
=
"Edge"
win_name
=
"Edge"
...
...
samples/python/facedetect.py
View file @
569b1ad5
...
@@ -7,7 +7,7 @@ Original C implementation by: ?
...
@@ -7,7 +7,7 @@ Original C implementation by: ?
Python implementation by: Roman Stanchak, James Bowman
Python implementation by: Roman Stanchak, James Bowman
"""
"""
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
from
optparse
import
OptionParser
from
optparse
import
OptionParser
# Parameters for haar detection
# Parameters for haar detection
...
...
samples/python/ffilldemo.py
View file @
569b1ad5
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
sys
import
sys
import
random
import
random
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
im
=
None
;
im
=
None
;
mask
=
None
;
mask
=
None
;
...
...
samples/python/fitellipse.py
View file @
569b1ad5
...
@@ -13,7 +13,7 @@ Python implementation by: Roman Stanchak, James Bowman
...
@@ -13,7 +13,7 @@ Python implementation by: Roman Stanchak, James Bowman
import
sys
import
sys
import
urllib2
import
urllib2
import
random
import
random
import
cv
import
cv
2.cv
as
cv
def
contour_iterator
(
contour
):
def
contour_iterator
(
contour
):
while
contour
:
while
contour
:
...
...
samples/python/houghlines.py
View file @
569b1ad5
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
sys
import
sys
from
math
import
sin
,
cos
,
sqrt
,
pi
from
math
import
sin
,
cos
,
sqrt
,
pi
import
cv
import
cv
2.cv
as
cv
import
urllib2
import
urllib2
# toggle between CV_HOUGH_STANDARD and CV_HOUGH_PROBILISTIC
# toggle between CV_HOUGH_STANDARD and CV_HOUGH_PROBILISTIC
...
...
samples/python/inpaint.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
class
Sketcher
:
class
Sketcher
:
def
__init__
(
self
,
windowname
,
dests
):
def
__init__
(
self
,
windowname
,
dests
):
...
...
samples/python/kalman.py
View file @
569b1ad5
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
Pressing ESC will stop the program.
Pressing ESC will stop the program.
"""
"""
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
from
math
import
cos
,
sin
,
sqrt
from
math
import
cos
,
sin
,
sqrt
import
sys
import
sys
...
...
samples/python/kmeans.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
from
random
import
randint
from
random
import
randint
MAX_CLUSTERS
=
5
MAX_CLUSTERS
=
5
...
...
samples/python/laplace.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
import
sys
import
sys
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
samples/python/lkdemo.py
View file @
569b1ad5
...
@@ -5,7 +5,7 @@ print "OpenCV Python version of lkdemo"
...
@@ -5,7 +5,7 @@ print "OpenCV Python version of lkdemo"
import
sys
import
sys
# import the necessary things for OpenCV
# import the necessary things for OpenCV
import
cv
import
cv
2.cv
as
cv
#############################################################################
#############################################################################
# some "constants"
# some "constants"
...
...
samples/python/logpolar.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
sys
import
sys
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
src
=
None
src
=
None
dst
=
None
dst
=
None
...
...
samples/python/minarea.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
from
random
import
randint
from
random
import
randint
def
roundxy
(
pt
):
def
roundxy
(
pt
):
...
...
samples/python/minidemo.py
View file @
569b1ad5
#! /usr/bin/env python
#! /usr/bin/env python
import
cv
import
cv
2.cv
as
cv
cap
=
cv
.
CreateFileCapture
(
"../c/tree.avi"
)
cap
=
cv
.
CreateFileCapture
(
"../c/tree.avi"
)
img
=
cv
.
QueryFrame
(
cap
)
img
=
cv
.
QueryFrame
(
cap
)
...
...
samples/python/morphology.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
sys
import
sys
import
urllib2
import
urllib2
import
cv
import
cv
2.cv
as
cv
src
=
0
src
=
0
image
=
0
image
=
0
...
...
samples/python/motempl.py
View file @
569b1ad5
...
@@ -3,7 +3,7 @@ import urllib2
...
@@ -3,7 +3,7 @@ import urllib2
import
sys
import
sys
import
time
import
time
from
math
import
cos
,
sin
from
math
import
cos
,
sin
import
cv
import
cv
2.cv
as
cv
CLOCKS_PER_SEC
=
1.0
CLOCKS_PER_SEC
=
1.0
MHI_DURATION
=
1
MHI_DURATION
=
1
...
...
samples/python/numpy_array.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
import
numpy
import
numpy
# SRGB-linear conversions using NumPy - see http://en.wikipedia.org/wiki/SRGB
# SRGB-linear conversions using NumPy - see http://en.wikipedia.org/wiki/SRGB
...
...
samples/python/numpy_warhol.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
import
numpy
import
numpy
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
samples/python/pyramid_segmentation.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
cv
import
cv
2.cv
as
cv
class
PyrSegmentation
:
class
PyrSegmentation
:
def
__init__
(
self
,
img0
):
def
__init__
(
self
,
img0
):
...
...
samples/python/squares.py
View file @
569b1ad5
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
import
urllib2
import
urllib2
from
math
import
sqrt
from
math
import
sqrt
import
cv
import
cv
2.cv
as
cv
thresh
=
50
thresh
=
50
img
=
None
img
=
None
...
...
samples/python/watershed.py
View file @
569b1ad5
#!/usr/bin/python
#!/usr/bin/python
import
urllib2
import
urllib2
import
sys
import
sys
import
cv
import
cv
2.cv
as
cv
class
Sketcher
:
class
Sketcher
:
def
__init__
(
self
,
windowname
,
dests
):
def
__init__
(
self
,
windowname
,
dests
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment