Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
ff9a1842
Commit
ff9a1842
authored
Aug 09, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1714 from paroj:ovis_texup
parents
a83b78e2
c655c310
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
6 deletions
+47
-6
ovis.hpp
modules/ovis/include/opencv2/ovis.hpp
+14
-1
ovis.cpp
modules/ovis/src/ovis.cpp
+33
-5
No files found.
modules/ovis/include/opencv2/ovis.hpp
View file @
ff9a1842
...
...
@@ -35,7 +35,11 @@ enum MaterialProperty
MATERIAL_POINT_SIZE
,
MATERIAL_OPACITY
,
MATERIAL_EMISSIVE
,
MATERIAL_TEXTURE
MATERIAL_TEXTURE0
,
MATERIAL_TEXTURE
=
MATERIAL_TEXTURE0
,
MATERIAL_TEXTURE1
,
MATERIAL_TEXTURE2
,
MATERIAL_TEXTURE3
,
};
enum
EntityProperty
...
...
@@ -281,6 +285,15 @@ CV_EXPORTS_W void createPointCloudMesh(const String& name, InputArray vertices,
* @param segments number of segments per side
*/
CV_EXPORTS_W
void
createGridMesh
(
const
String
&
name
,
const
Size2f
&
size
,
const
Size
&
segments
=
Size
(
1
,
1
));
/**
* updates an existing texture
*
* A new texture can be created with @ref createPlaneMesh
* @param name name of the texture
* @param image the image data
*/
CV_EXPORTS_W
void
updateTexture
(
const
String
&
name
,
InputArray
image
);
//! @}
}
}
...
...
modules/ovis/src/ovis.cpp
View file @
ff9a1842
...
...
@@ -31,11 +31,28 @@ WindowScene::~WindowScene() {}
void
_createTexture
(
const
String
&
name
,
Mat
image
)
{
PixelFormat
format
;
switch
(
image
.
type
())
{
case
CV_8UC4
:
format
=
PF_BYTE_BGRA
;
break
;
case
CV_8UC3
:
format
=
PF_BYTE_BGR
;
break
;
case
CV_8UC1
:
format
=
PF_BYTE_L
;
break
;
default
:
CV_Error
(
Error
::
StsBadArg
,
"currently only CV_8UC1, CV_8UC3, CV_8UC4 textures are supported"
);
break
;
}
TextureManager
&
texMgr
=
TextureManager
::
getSingleton
();
TexturePtr
tex
=
texMgr
.
getByName
(
name
,
RESOURCEGROUP_NAME
);
Image
im
;
im
.
loadDynamicImage
(
image
.
ptr
(),
image
.
cols
,
image
.
rows
,
1
,
PF_BYTE_BGR
);
im
.
loadDynamicImage
(
image
.
ptr
(),
image
.
cols
,
image
.
rows
,
1
,
format
);
if
(
tex
)
{
...
...
@@ -323,7 +340,7 @@ public:
void
setBackground
(
InputArray
image
)
{
CV_Assert
(
image
.
type
()
==
CV_8UC3
,
bgplane
);
CV_Assert
(
bgplane
);
String
name
=
sceneMgr
->
getName
()
+
"_Background"
;
...
...
@@ -700,20 +717,23 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
void
setMaterialProperty
(
const
String
&
name
,
int
prop
,
const
String
&
value
)
{
CV_Assert
(
prop
==
MATERIAL_TEXTURE
,
_app
);
CV_Assert
(
prop
>=
MATERIAL_TEXTURE0
,
prop
<=
MATERIAL_TEXTURE3
,
_app
);
MaterialPtr
mat
=
MaterialManager
::
getSingleton
().
getByName
(
name
,
RESOURCEGROUP_NAME
);
CV_Assert
(
mat
);
Pass
*
rpass
=
mat
->
getTechniques
()[
0
]
->
getPasses
()[
0
];
if
(
rpass
->
getTextureUnitStates
().
empty
())
size_t
texUnit
=
prop
-
MATERIAL_TEXTURE0
;
CV_Assert
(
texUnit
<=
rpass
->
getTextureUnitStates
().
size
());
if
(
rpass
->
getTextureUnitStates
().
size
()
<=
texUnit
)
{
rpass
->
createTextureUnitState
(
value
);
return
;
}
rpass
->
getTextureUnitStates
()[
0
]
->
setTextureName
(
value
);
rpass
->
getTextureUnitStates
()[
texUnit
]
->
setTextureName
(
value
);
}
static
bool
setShaderProperty
(
const
GpuProgramParametersSharedPtr
&
params
,
const
String
&
prop
,
...
...
@@ -770,5 +790,13 @@ void setMaterialProperty(const String& name, const String& prop, const Scalar& v
if
(
!
set
)
CV_Error_
(
Error
::
StsBadArg
,
(
"shader parameter named '%s' not found"
,
prop
.
c_str
()));
}
void
updateTexture
(
const
String
&
name
,
InputArray
image
)
{
CV_Assert
(
_app
);
TexturePtr
tex
=
TextureManager
::
getSingleton
().
getByName
(
name
,
RESOURCEGROUP_NAME
);
CV_Assert
(
tex
);
_createTexture
(
name
,
image
.
getMat
());
}
}
}
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