Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
54a7e4af
Commit
54a7e4af
authored
Aug 14, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a few comments
parent
9e9cddab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
include/eos/render/Mesh.hpp
include/eos/render/Mesh.hpp
+2
-2
include/eos/render/detail/render_detail.hpp
include/eos/render/detail/render_detail.hpp
+7
-1
include/eos/render/detail/texture_extraction_detail.hpp
include/eos/render/detail/texture_extraction_detail.hpp
+6
-0
include/eos/render/texture_extraction.hpp
include/eos/render/texture_extraction.hpp
+6
-0
No files found.
include/eos/render/Mesh.hpp
View file @
54a7e4af
...
...
@@ -49,7 +49,7 @@ namespace eos {
struct
Mesh
{
std
::
vector
<
cv
::
Vec4f
>
vertices
;
///< 3D vertex positions.
std
::
vector
<
cv
::
Vec3f
>
colors
;
///< Color information for each vertex. Expected to be in RGB order.
std
::
vector
<
cv
::
Vec3f
>
colors
;
///< Colo
u
r information for each vertex. Expected to be in RGB order.
std
::
vector
<
cv
::
Vec2f
>
texcoords
;
///< Texture coordinates for each vertex.
std
::
vector
<
std
::
array
<
int
,
3
>>
tvi
;
///< Triangle vertex indices
...
...
@@ -145,7 +145,7 @@ inline void write_textured_obj(Mesh mesh, std::string filename)
mtl_file
<<
"map_Kd "
<<
texture_filename
.
string
()
<<
std
::
endl
;
return
;
}
}
;
}
/* namespace render */
}
/* namespace eos */
...
...
include/eos/render/detail/render_detail.hpp
View file @
54a7e4af
...
...
@@ -166,11 +166,17 @@ struct TriangleToRasterize
*/
cv
::
Rect
calculate_clipped_bounding_box
(
cv
::
Vec4f
v0
,
cv
::
Vec4f
v1
,
cv
::
Vec4f
v2
,
int
viewport_width
,
int
viewport_height
)
{
/* Old, producing artifacts:
t.minX = max(min(t.v0.position[0], min(t.v1.position[0], t.v2.position[0])), 0.0f);
t.maxX = min(max(t.v0.position[0], max(t.v1.position[0], t.v2.position[0])), (float)(viewportWidth - 1));
t.minY = max(min(t.v0.position[1], min(t.v1.position[1], t.v2.position[1])), 0.0f);
t.maxY = min(max(t.v0.position[1], max(t.v1.position[1], t.v2.position[1])), (float)(viewportHeight - 1));*/
using
std
::
min
;
using
std
::
max
;
using
std
::
floor
;
using
std
::
ceil
;
int
minX
=
max
(
min
(
floor
(
v0
[
0
]),
min
(
floor
(
v1
[
0
]),
floor
(
v2
[
0
]))),
0.0
f
);
int
minX
=
max
(
min
(
floor
(
v0
[
0
]),
min
(
floor
(
v1
[
0
]),
floor
(
v2
[
0
]))),
0.0
f
);
// Readded this comment after merge: What about rounding, or rather the conversion from double to int?
int
maxX
=
min
(
max
(
ceil
(
v0
[
0
]),
max
(
ceil
(
v1
[
0
]),
ceil
(
v2
[
0
]))),
static_cast
<
float
>
(
viewport_width
-
1
));
int
minY
=
max
(
min
(
floor
(
v0
[
1
]),
min
(
floor
(
v1
[
1
]),
floor
(
v2
[
1
]))),
0.0
f
);
int
maxY
=
min
(
max
(
ceil
(
v0
[
1
]),
max
(
ceil
(
v1
[
1
]),
ceil
(
v2
[
1
]))),
static_cast
<
float
>
(
viewport_height
-
1
));
...
...
include/eos/render/detail/texture_extraction_detail.hpp
View file @
54a7e4af
...
...
@@ -73,6 +73,12 @@ inline bool is_point_in_triangle(cv::Point2f point, cv::Point2f triV0, cv::Point
* The vertices should be given in screen coordinates, but with their
* z-values preserved, so they can be compared against the depthbuffer.
*
* Obviously the depthbuffer given should have been created with the same projection
* matrix than the texture extraction is called with.
*
* Also, we don't do perspective-correct interpolation here I think, so only
* use it with affine and orthographic projection matrices.
*
* @param[in] v0 First vertex, in screen coordinates (but still with their z-value).
* @param[in] v1 Second vertex.
* @param[in] v2 Third vertex.
...
...
include/eos/render/texture_extraction.hpp
View file @
54a7e4af
...
...
@@ -53,6 +53,8 @@ inline cv::Mat extract_texture(Mesh mesh, cv::Mat affine_camera_matrix, cv::Mat
* Extracts the texture of the face from the given image
* and stores it as isomap (a rectangular texture map).
*
* Todo: These should be renamed to extract_texture_affine? Can we combine both cases somehow?
*
* @param[in] mesh A mesh with texture coordinates.
* @param[in] affine_camera_matrix An estimated 3x4 affine camera matrix.
* @param[in] image The image to extract the texture from.
...
...
@@ -78,6 +80,10 @@ inline cv::Mat extract_texture(Mesh mesh, cv::Mat affine_camera_matrix, cv::Mat
* To just run the texture extraction, see the overload
* extract_texture(Mesh, cv::Mat, cv::Mat, TextureInterpolation, int).
*
* It might be wise to remove this overload as it can get quite confusing
* with the zbuffer. Obviously the depthbuffer given should have been created
* with the same (affine or ortho) projection matrix than the texture extraction is called with.
*
* @param[in] mesh A mesh with texture coordinates.
* @param[in] affine_camera_matrix An estimated 3x4 affine camera matrix.
* @param[in] image The image to extract the texture from.
...
...
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