Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d6c6c3ec
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d6c6c3ec
编写于
6月 23, 2010
作者:
J
James Bowman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#393, SnakeImage
上级
122a1c2b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
9 deletion
+67
-9
modules/python/api
modules/python/api
+9
-0
modules/python/cv.cpp
modules/python/cv.cpp
+38
-9
tests/python/test.py
tests/python/test.py
+20
-0
未找到文件。
modules/python/api
浏览文件 @
d6c6c3ec
...
...
@@ -1499,6 +1499,15 @@ KalmanCorrect ROCvMat*
KalmanPredict ROCvMat*
CvKalman* kalman
CvMat control NULL
SnakeImage points
IplImage image
CvPoints points
floats alpha
floats beta
floats gamma
CvSize win
CvTermCriteria criteria
int calc_gradient 1
# Optical Flow
CalcOpticalFlowLK
...
...
modules/python/cv.cpp
浏览文件 @
d6c6c3ec
...
...
@@ -1812,16 +1812,24 @@ struct floats {
};
static
int
convert_to_floats
(
PyObject
*
o
,
floats
*
dst
,
const
char
*
name
=
"no_name"
)
{
PyObject
*
fi
=
PySequence_Fast
(
o
,
name
);
if
(
fi
==
NULL
)
return
0
;
dst
->
count
=
PySequence_Fast_GET_SIZE
(
fi
);
dst
->
f
=
new
float
[
dst
->
count
];
for
(
Py_ssize_t
i
=
0
;
i
<
PySequence_Fast_GET_SIZE
(
fi
);
i
++
)
{
PyObject
*
item
=
PySequence_Fast_GET_ITEM
(
fi
,
i
);
dst
->
f
[
i
]
=
(
float
)
PyFloat_AsDouble
(
item
);
if
(
PySequence_Check
(
o
))
{
PyObject
*
fi
=
PySequence_Fast
(
o
,
name
);
if
(
fi
==
NULL
)
return
0
;
dst
->
count
=
PySequence_Fast_GET_SIZE
(
fi
);
dst
->
f
=
new
float
[
dst
->
count
];
for
(
Py_ssize_t
i
=
0
;
i
<
PySequence_Fast_GET_SIZE
(
fi
);
i
++
)
{
PyObject
*
item
=
PySequence_Fast_GET_ITEM
(
fi
,
i
);
dst
->
f
[
i
]
=
(
float
)
PyFloat_AsDouble
(
item
);
}
Py_DECREF
(
fi
);
}
else
if
(
PyNumber_Check
(
o
))
{
dst
->
count
=
1
;
dst
->
f
=
new
float
[
1
];
dst
->
f
[
0
]
=
PyFloat_AsDouble
(
o
);
}
else
{
return
failmsg
(
"Expected list of floats, or float for argument '%s'"
,
name
);
}
Py_DECREF
(
fi
);
return
1
;
}
...
...
@@ -2552,6 +2560,16 @@ static PyObject *FROM_CvSubdiv2DEdge(CvSubdiv2DEdge r)
return
(
PyObject
*
)
m
;
}
static
PyObject
*
FROM_CvPoints
(
CvPoints
src
)
{
PyObject
*
pr
;
pr
=
PyList_New
(
src
.
count
);
for
(
int
i
=
0
;
i
<
src
.
count
;
i
++
)
{
PyList_SetItem
(
pr
,
i
,
FROM_CvPoint
(
src
.
p
[
i
]));
}
return
pr
;
}
/************************************************************************/
/* A few functions are too odd to be generated,
...
...
@@ -3763,6 +3781,17 @@ static int zero = 0;
#define constCvMat const CvMat
#define FROM_constCvMatPTR(x) FROM_CvMatPTR((CvMat*)x)
#define cvSnakeImage(image, points, length, a, b, g, win, criteria, calc_gradient) \
do { \
int coeff_usage; \
if ((alpha.count == 1) && (beta.count == 1) && (gamma.count == 1)) \
coeff_usage = CV_VALUE; \
else if ((length == alpha.count) && (alpha.count == beta.count) && (beta.count == gamma.count)) \
coeff_usage = CV_ARRAY; \
else \
return (PyObject*)failmsg("SnakeImage weights invalid"); \
cvSnakeImage(image, points, length, a, b, g, coeff_usage, win, criteria, calc_gradient); \
} while (0)
#include "generated0.i"
...
...
tests/python/test.py
浏览文件 @
d6c6c3ec
...
...
@@ -770,6 +770,26 @@ class FunctionTests(OpenCVTests):
expected
=
0.0
self
.
assertEqual
(
M
[
rj
,
cj
],
expected
)
def
test_SnakeImage
(
self
):
src
=
self
.
get_sample
(
"samples/c/lena.jpg"
,
0
)
pts
=
[
(
512
-
i
,
i
)
for
i
in
range
(
0
,
512
,
8
)
]
# Make sure that weight arguments get validated
self
.
assertRaises
(
TypeError
,
lambda
:
cv
.
SnakeImage
(
cv
.
GetImage
(
src
),
pts
,
[
1
,
2
],
.
01
,
.
01
,
(
7
,
7
),
(
cv
.
CV_TERMCRIT_ITER
,
100
,
0.1
)))
# Smoke by making sure that points are changed by call
r
=
cv
.
SnakeImage
(
cv
.
GetImage
(
src
),
pts
,
.
01
,
.
01
,
.
01
,
(
7
,
7
),
(
cv
.
CV_TERMCRIT_ITER
,
100
,
0.1
))
if
0
:
cv
.
PolyLine
(
src
,
[
r
],
0
,
255
)
self
.
snap
(
src
)
self
.
assertEqual
(
len
(
r
),
len
(
pts
))
self
.
assertNotEqual
(
r
,
pts
)
# Ensure that list of weights is same as scalar weight
w
=
[.
01
]
*
len
(
pts
)
r2
=
cv
.
SnakeImage
(
cv
.
GetImage
(
src
),
pts
,
w
,
w
,
w
,
(
7
,
7
),
(
cv
.
CV_TERMCRIT_ITER
,
100
,
0.1
))
self
.
assertEqual
(
r
,
r2
)
def
test_Sum
(
self
):
for
r
in
range
(
1
,
11
):
for
c
in
range
(
1
,
11
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录