Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
625c35a9
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
625c35a9
编写于
1月 13, 2014
作者:
A
Anatoly Baksheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added support of texture for mesh
上级
74206e01
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
99 addition
and
6 deletion
+99
-6
modules/viz/include/opencv2/viz.hpp
modules/viz/include/opencv2/viz.hpp
+5
-0
modules/viz/include/opencv2/viz/types.hpp
modules/viz/include/opencv2/viz/types.hpp
+2
-0
modules/viz/src/clouds.cpp
modules/viz/src/clouds.cpp
+30
-3
modules/viz/src/vizcore.cpp
modules/viz/src/vizcore.cpp
+2
-0
modules/viz/src/vtk/vtkCloudMatSource.cpp
modules/viz/src/vtk/vtkCloudMatSource.cpp
+53
-1
modules/viz/src/vtk/vtkCloudMatSource.h
modules/viz/src/vtk/vtkCloudMatSource.h
+7
-2
未找到文件。
modules/viz/include/opencv2/viz.hpp
浏览文件 @
625c35a9
...
...
@@ -98,6 +98,11 @@ namespace cv
CV_EXPORTS
void
writeCloud
(
const
String
&
file
,
InputArray
cloud
,
InputArray
colors
=
noArray
(),
InputArray
normals
=
noArray
(),
bool
binary
=
false
);
CV_EXPORTS
Mat
readCloud
(
const
String
&
file
,
OutputArray
colors
=
noArray
(),
OutputArray
normals
=
noArray
());
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read mesh. Only ply format is supported now
CV_EXPORTS
Mesh
readMesh
(
const
String
&
file
);
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read/write poses and trajectories
...
...
modules/viz/include/opencv2/viz/types.hpp
浏览文件 @
625c35a9
...
...
@@ -113,6 +113,8 @@ namespace cv
//! where n is the number of points in the poligon, and id is a zero-offset index into an associated cloud.
Mat
polygons
;
Mat
texture
,
tcoords
;
//! Loads mesh from a given ply file
static
Mesh
load
(
const
String
&
file
);
};
...
...
modules/viz/src/clouds.cpp
浏览文件 @
625c35a9
...
...
@@ -95,8 +95,25 @@ cv::viz::WPaintedCloud::WPaintedCloud(InputArray cloud)
Vec6d
bounds
(
cloud_source
->
GetOutput
()
->
GetPoints
()
->
GetBounds
());
WPaintedCloud
cloud_widget
(
cloud
,
Vec3d
(
bounds
[
0
],
bounds
[
2
],
bounds
[
4
]),
Vec3d
(
bounds
[
1
],
bounds
[
3
],
bounds
[
5
]));
*
this
=
cloud_widget
;
vtkSmartPointer
<
vtkElevationFilter
>
elevation
=
vtkSmartPointer
<
vtkElevationFilter
>::
New
();
elevation
->
SetInputConnection
(
cloud_source
->
GetOutputPort
());
elevation
->
SetLowPoint
(
bounds
[
0
],
bounds
[
2
],
bounds
[
4
]);
elevation
->
SetHighPoint
(
bounds
[
1
],
bounds
[
3
],
bounds
[
5
]);
elevation
->
SetScalarRange
(
0.0
,
1.0
);
elevation
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
VtkUtils
::
SetInputData
(
mapper
,
vtkPolyData
::
SafeDownCast
(
elevation
->
GetOutput
()));
mapper
->
ImmediateModeRenderingOff
();
mapper
->
ScalarVisibilityOn
();
mapper
->
SetColorModeToMapScalars
();
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
GetProperty
()
->
SetInterpolationToFlat
();
actor
->
GetProperty
()
->
BackfaceCullingOn
();
actor
->
SetMapper
(
mapper
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
cv
::
viz
::
WPaintedCloud
::
WPaintedCloud
(
InputArray
cloud
,
const
Point3d
&
p1
,
const
Point3d
&
p2
)
...
...
@@ -329,7 +346,7 @@ cv::viz::WMesh::WMesh(const Mesh &mesh)
CV_Assert
(
mesh
.
cloud
.
rows
==
1
&&
mesh
.
polygons
.
type
()
==
CV_32SC1
);
vtkSmartPointer
<
vtkCloudMatSource
>
source
=
vtkSmartPointer
<
vtkCloudMatSource
>::
New
();
source
->
SetColorCloud
(
mesh
.
cloud
,
mesh
.
color
s
);
source
->
SetColorCloud
NormalsTCoords
(
mesh
.
cloud
,
mesh
.
colors
,
mesh
.
normals
,
mesh
.
tcoord
s
);
source
->
Update
();
Mat
lookup_buffer
(
1
,
mesh
.
cloud
.
total
(),
CV_32SC1
);
...
...
@@ -394,6 +411,16 @@ cv::viz::WMesh::WMesh(const Mesh &mesh)
actor
->
GetProperty
()
->
ShadingOff
();
actor
->
SetMapper
(
mapper
);
if
(
!
mesh
.
texture
.
empty
())
{
vtkSmartPointer
<
vtkImageMatSource
>
image_source
=
vtkSmartPointer
<
vtkImageMatSource
>::
New
();
image_source
->
SetImage
(
mesh
.
texture
);
vtkSmartPointer
<
vtkTexture
>
texture
=
vtkSmartPointer
<
vtkTexture
>::
New
();
texture
->
SetInputConnection
(
image_source
->
GetOutputPort
());
actor
->
SetTexture
(
texture
);
}
WidgetAccessor
::
setProp
(
*
this
,
actor
);
}
...
...
modules/viz/src/vizcore.cpp
浏览文件 @
625c35a9
...
...
@@ -205,6 +205,8 @@ cv::Mat cv::viz::readCloud(const String& file, OutputArray colors, OutputArray n
return
cloud
;
}
cv
::
viz
::
Mesh
cv
::
viz
::
readMesh
(
const
String
&
file
)
{
return
Mesh
::
load
(
file
);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// Read/write poses and trajectories
...
...
modules/viz/src/vtk/vtkCloudMatSource.cpp
浏览文件 @
625c35a9
...
...
@@ -128,7 +128,34 @@ int cv::viz::vtkCloudMatSource::SetColorCloudNormals(InputArray _cloud, InputArr
else
if
(
normals
.
depth
()
==
CV_64F
&&
cloud
.
depth
()
==
CV_64F
)
filterNanNormalsCopy
<
double
,
double
>
(
normals
,
cloud
,
total
);
else
CV_Assert
(
!
"Unsupported normals type"
);
CV_Assert
(
!
"Unsupported normals/cloud type"
);
return
total
;
}
int
cv
::
viz
::
vtkCloudMatSource
::
SetColorCloudNormalsTCoords
(
InputArray
_cloud
,
InputArray
_colors
,
InputArray
_normals
,
InputArray
_tcoords
)
{
int
total
=
SetColorCloudNormals
(
_cloud
,
_colors
,
_normals
);
if
(
_tcoords
.
empty
())
return
total
;
CV_Assert
(
_tcoords
.
depth
()
==
CV_32F
||
_tcoords
.
depth
()
==
CV_64F
);
CV_Assert
(
_tcoords
.
channels
()
==
2
&&
_tcoords
.
size
()
==
_cloud
.
size
());
Mat
cloud
=
_cloud
.
getMat
();
Mat
tcoords
=
_tcoords
.
getMat
();
if
(
tcoords
.
depth
()
==
CV_32F
&&
cloud
.
depth
()
==
CV_32F
)
filterNanTCoordsCopy
<
float
,
float
>
(
tcoords
,
cloud
,
total
);
else
if
(
tcoords
.
depth
()
==
CV_32F
&&
cloud
.
depth
()
==
CV_64F
)
filterNanTCoordsCopy
<
float
,
double
>
(
tcoords
,
cloud
,
total
);
else
if
(
tcoords
.
depth
()
==
CV_64F
&&
cloud
.
depth
()
==
CV_32F
)
filterNanTCoordsCopy
<
double
,
float
>
(
tcoords
,
cloud
,
total
);
else
if
(
tcoords
.
depth
()
==
CV_64F
&&
cloud
.
depth
()
==
CV_64F
)
filterNanTCoordsCopy
<
double
,
double
>
(
tcoords
,
cloud
,
total
);
else
CV_Assert
(
!
"Unsupported tcoords/cloud type"
);
return
total
;
}
...
...
@@ -146,6 +173,9 @@ int cv::viz::vtkCloudMatSource::RequestData(vtkInformation *vtkNotUsed(request),
if
(
normals
)
output
->
GetPointData
()
->
SetNormals
(
normals
);
if
(
tcoords
)
output
->
GetPointData
()
->
SetTCoords
(
tcoords
);
return
1
;
}
...
...
@@ -232,3 +262,25 @@ void cv::viz::vtkCloudMatSource::filterNanNormalsCopy(const Mat& cloud_normals,
normals
->
SetTuple
(
pos
++
,
srow
);
}
}
template
<
typename
_Tn
,
typename
_Msk
>
void
cv
::
viz
::
vtkCloudMatSource
::
filterNanTCoordsCopy
(
const
Mat
&
_tcoords
,
const
Mat
&
mask
,
int
total
)
{
typedef
Vec
<
_Tn
,
2
>
Vec2
;
tcoords
=
vtkSmartPointer
<
VtkDepthTraits
<
_Tn
>::
array_type
>::
New
();
tcoords
->
SetName
(
"TextureCoordinates"
);
tcoords
->
SetNumberOfComponents
(
2
);
tcoords
->
SetNumberOfTuples
(
total
);
int
pos
=
0
;
for
(
int
y
=
0
;
y
<
mask
.
rows
;
++
y
)
{
const
Vec2
*
srow
=
_tcoords
.
ptr
<
Vec2
>
(
y
);
const
Vec2
*
send
=
srow
+
_tcoords
.
cols
;
const
_Msk
*
mrow
=
mask
.
ptr
<
_Msk
>
(
y
);
for
(;
srow
!=
send
;
++
srow
,
mrow
+=
mask
.
channels
())
if
(
!
isNan
(
mrow
))
tcoords
->
SetTuple
(
pos
++
,
srow
->
val
);
}
}
modules/viz/src/vtk/vtkCloudMatSource.h
浏览文件 @
625c35a9
...
...
@@ -62,8 +62,9 @@ namespace cv
vtkTypeMacro
(
vtkCloudMatSource
,
vtkPolyDataAlgorithm
)
virtual
int
SetCloud
(
InputArray
cloud
);
virtual
int
SetColorCloud
(
InputArray
cloud
,
InputArray
colors
=
noArray
());
virtual
int
SetColorCloudNormals
(
InputArray
cloud
,
InputArray
colors
=
noArray
(),
InputArray
normals
=
noArray
());
virtual
int
SetColorCloud
(
InputArray
cloud
,
InputArray
colors
);
virtual
int
SetColorCloudNormals
(
InputArray
cloud
,
InputArray
colors
,
InputArray
normals
);
virtual
int
SetColorCloudNormalsTCoords
(
InputArray
cloud
,
InputArray
colors
,
InputArray
normals
,
InputArray
tcoords
);
protected:
vtkCloudMatSource
();
...
...
@@ -75,6 +76,7 @@ namespace cv
vtkSmartPointer
<
vtkCellArray
>
vertices
;
vtkSmartPointer
<
vtkUnsignedCharArray
>
scalars
;
vtkSmartPointer
<
vtkDataArray
>
normals
;
vtkSmartPointer
<
vtkDataArray
>
tcoords
;
private:
vtkCloudMatSource
(
const
vtkCloudMatSource
&
);
// Not implemented.
void
operator
=
(
const
vtkCloudMatSource
&
);
// Not implemented.
...
...
@@ -84,6 +86,9 @@ namespace cv
template
<
typename
_Tn
,
typename
_Msk
>
void
filterNanNormalsCopy
(
const
Mat
&
cloud_normals
,
const
Mat
&
mask
,
int
total
);
template
<
typename
_Tn
,
typename
_Msk
>
void
filterNanTCoordsCopy
(
const
Mat
&
tcoords
,
const
Mat
&
mask
,
int
total
);
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录