SlideShare a Scribd company logo
1 of 6
Download to read offline
Zachary Job
11/27/15
CS 532
Professor Mordohai
HW6
NOTE:
There’s a good chunk of code… I took an approach of listing what the code does in what file
starting at what line.
Problem 1:
Since it sounded like drawing lines was not exactly essential, I made an informative text output.
The algorithm is very simple and I checked a point so I don’t think it could mess up beyond a loss of
precision here and there. I took to creating a bucket per vertex where faces where added if they had this
vertex. Knowing calculating the normals for each connected face was needed, this solution seemed fit.
The code…
 Get the user specified file names – line 31 mgr.c
 Enter the read ply function to load the data – line 40 mgr.c
o Initialize base conditions – line 185 readPLY.c
o Load the file to memory – line 119, 212 readPLY.c
o Find the header for processing – line 221, 232 readPLY.c
o Given there is no defined order for variables, set a list of offsets so – line 239 readPLY.c
o Depending on which element was specified first, find the offset into the next element
given order matters in my implementation – line 293 readPLY.c
o Enter loadVerts to load the vertices – line 313 readPLY.c
 Initialize the vertex list, the vertex face buckets, and the result list – line 34
readPLY.c, loadVerts
 Get the current line or vertex data – line 44 readPLY.c, loadVerts
 Break it into tokens – line 49 readPLY.c, loadVerts
 Read the tokens into doubles with acceptable precision – line 60 readPLY.c,
loadVerts
 Use this loop to initialize the bucket data – line 66
o Enter loadFaces to load the faces – line 315 readPLY.c
 Initialize the face list – line 96 readPLY.c, loadFaces
 Get the current line or face data – line 103 readPLY.c, loadFace
 Break it into tokens – line 108 readPLY.c, loadFaces
 Assign the tokens as int representations of the tokens – line 116 readPLY.c,
loadFaces
 Enter calculateNormals to use the bucketed data to find the normal – line 47 mgr.c
o Iterate every bucket or every vertex – line 30 calcualteNormals.c
o Initialize the normals to be safe – line 32 calculateNormals.c
o Iterate the bucket at the vertex index – line 37 calculateNormals.c
o Find the normals with a point based formula – line 40, 49 calculateNormals.c
o Produce the unit vector – line 54 calculateNormals.c
o Average BUT do not get the unit vector for printing later – line 62 calculateNormals.c
 Enter writeNormals to use all gathered information to make sensible output – line 54 mgr.c
o Iterate each bucket – line 37 writeNorms.c
o Write the vertex information including the normal and unit vector correction – line 44
writeNorms.c
o Iterate the bucket to list the faces used – line 65 writeNorms.c
o Write the buffer – line 77 writeNorms.c
The results appear acceptable, and one was randomly selected and passed. I do not see any
frailty in this code. It’s a basic algorithm and for what it seems everything works. The only fault would be
if the wrong faces were bucketed which I can’t see how that would go wrong.
This can be found in SRC_1/DATA/TXT/…
Problem 2:
My major delay here was actually that I was messing around and wanted to try an algorithm to
push out from a line with a left right selector and enqueue line sides which did not have a face. It was
just a heap of code I didn’t need to finish the assignment.
I took to a “zipper” algorithm instead as it could be accomplished fast and made for easy
debugging. This works on a super simple concept given we were allowed to drop vertices (which it did
not create holes for this instance). Using the depth map… Iterate every column. Look from the top down
for a new line, or pair of points. To finish it then would look for one point in the column to the right. The
next start point for another line would then lock to the last point found for the initial line. For every two
faces there could be closure to create a new face by drawing a line. As a vertex is used it too is projected
and colored to ease writing the ply result soon after.
The code…
 Take the user input and jump to initData to setup the data – line 33 mgr.c
o Initialize base cases – line 31, 37 initData.c
o Ignore my shenanigans with checking for NULLs, I was getting frustrated with a memory
leak – line 48 initData.c
o Use grayToDouble pgm loader to get the user specified disparity – line 57 initData.c
 No need to elaborate, this is a wrapper for your old ppm code slightly modified
o Use pixelToDouble ppm loader to get the user specified colors – line 60 initData.c
 No need to elaborate, this is a wrapper for your old ppm code slightly modified
o Load the needed information eg focal information with acceptable precision – line 63,
70, 77 initData.c
 Calculate the mesh, color the vertices, and project them all at once by calling calculateMesh –
line 36 mgr.c
o Allocate and set a list to the number of vertices in the previous column. This is used to
find offsets into lists of elements – line 35, 38 calculateMesh.c
o Initialize the now know amount of vertices – line 49 calculateMesh.c
o Iterate each column to perform the zipper operation on it and its leftmost neighbor –
line 58 calculateMesh.c
o Get the offsets into the vertex list of the vertices per the used columns – line 61
calculateMesh.c
o Iterate downwards on these two columns stopping when there are not enough or
appropriate vertices to form a face – line 65 calculateMesh.c
o Seek two vertices from the left column snapping v1 to either the first or last left vertex
found (v2) – line 69 calculateMesh.c
o Seek one vertex from the right column – line 86 calculateMesh.c
o Allocate and set the new faces vertices – line 93, 98 calculateMesh.c
(Note: confidence and intensity are debugging artifacts)
o Project and color v1 if it is the first vertex selected in the left column – line 103
calculateMesh.c
o Repeat regardless for v2 and v3 given with a match they must contain new vertices, but
first adjust the line height given ++ skews the result by one in the for loops.. I could of
handled that differently – line 128, 152 calculateMesh.c
o If enough faces where found to create a new triangle by drawing between the right
column matched vertices, generate additional faces. Do not work on the vertices given
they had to have been manipulated already if they are part of existing faces – line 181
calculateMesh.c
 Write a ply to display the newfound mesh using writePLY – line 52 mgr.c
o Generate a header via using a fixed format and inserting the vertex and face counts –
line 44 writePLY.c
o Write the header – line 54 writePLY.c
o For each vertex write out its needed information from a generated buffer – line 59
writePLY.c
o For each face write out its needed information from a generated buffer – line 74
writePLY.c
For this problem the results were visual so really any mistake was not hard to catch. It can be
seen this algorithm has plenty that could be done better. Smoothing of sorts for one thing would be a
good step. However it got the job done. There is significant stretching especially where the disparity
could not show. Also, please note the coloring exists, however it is hard to notice given the edges are
colored on the triangles. I didn’t think it necessary to rectify it because I have evidence of the texture.
These can be found in SRC_2/DATA/SNAPS/…
Proof of color, see the texture is apparent at this angle however faded due to stretching and the edge
coloring
Side one
Side two, note the stretching from the lacking or more distant points
Additional visuals from the top and bottom showcasing what could be and could not be captured by the
depth map. They also show overall stretching
Top
Bottom
Although messy, this is a functional representation of the blanket

More Related Content

What's hot

Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Clipping in 2 d
Clipping in 2 dClipping in 2 d
Clipping in 2 dAshiv Khan
 
Bhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh Panchal
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmMani Kanth
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingAnkit Garg
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_projectManish Jauhari
 
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping2013901097
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementIJMER
 
Random numbers c++ class 11 and 12
Random numbers c++  class 11 and 12Random numbers c++  class 11 and 12
Random numbers c++ class 11 and 12SATHASIVAN H
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clippingMani Kanth
 

What's hot (19)

06 clipping
06 clipping06 clipping
06 clipping
 
Clipping
ClippingClipping
Clipping
 
Clipping2
Clipping2Clipping2
Clipping2
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping in 2 d
Clipping in 2 dClipping in 2 d
Clipping in 2 d
 
Clipping
ClippingClipping
Clipping
 
Boundary fill algm
Boundary fill algmBoundary fill algm
Boundary fill algm
 
Bhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh window clipping slidshare
Bhavesh window clipping slidshare
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Writeup advanced lane_lines_project
Writeup advanced lane_lines_projectWriteup advanced lane_lines_project
Writeup advanced lane_lines_project
 
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping
 
Comparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for ImprovementComparison of Various Line Clipping Algorithm for Improvement
Comparison of Various Line Clipping Algorithm for Improvement
 
Random numbers c++ class 11 and 12
Random numbers c++  class 11 and 12Random numbers c++  class 11 and 12
Random numbers c++ class 11 and 12
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 

Viewers also liked

Viewers also liked (15)

Sample_HArchitecture
Sample_HArchitectureSample_HArchitecture
Sample_HArchitecture
 
stigbot_beta
stigbot_betastigbot_beta
stigbot_beta
 
Portfolio project
Portfolio projectPortfolio project
Portfolio project
 
Young Professionals Summit Brochure
Young Professionals Summit BrochureYoung Professionals Summit Brochure
Young Professionals Summit Brochure
 
Principios de la prueba
Principios de la pruebaPrincipios de la prueba
Principios de la prueba
 
Sample_HEngineering
Sample_HEngineeringSample_HEngineering
Sample_HEngineering
 
The Los Angeles Times
The Los Angeles TimesThe Los Angeles Times
The Los Angeles Times
 
Tic´s trabajo de investigacion
Tic´s trabajo de investigacionTic´s trabajo de investigacion
Tic´s trabajo de investigacion
 
Brussels Forum
Brussels ForumBrussels Forum
Brussels Forum
 
Pong
PongPong
Pong
 
Sample_RWEngineering
Sample_RWEngineeringSample_RWEngineering
Sample_RWEngineering
 
fpres
fpresfpres
fpres
 
677_Project_Report_V2
677_Project_Report_V2677_Project_Report_V2
677_Project_Report_V2
 
Dimensión negra
Dimensión negraDimensión negra
Dimensión negra
 
Legal Issues In Beverage Alcohol Caffeinated Beverages (FINAL)
Legal Issues In Beverage Alcohol  Caffeinated Beverages (FINAL)Legal Issues In Beverage Alcohol  Caffeinated Beverages (FINAL)
Legal Issues In Beverage Alcohol Caffeinated Beverages (FINAL)
 

Similar to Mesh Generation from Depth Maps

Similar to Mesh Generation from Depth Maps (20)

"contour.py" module
"contour.py" module"contour.py" module
"contour.py" module
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
C_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docx
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
 
50_coding_challengesfffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
50_coding_challengesfffffffffffffffffffffffffffffffffffffffffffffffffffffffff...50_coding_challengesfffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
50_coding_challengesfffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
 
Crack the interview
Crack the interviewCrack the interview
Crack the interview
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Programming questions
Programming questionsProgramming questions
Programming questions
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Hungarian Method
Hungarian MethodHungarian Method
Hungarian Method
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
 
Answer SheetInstructions You must show your work to .docx
Answer SheetInstructions  You must show your work to .docxAnswer SheetInstructions  You must show your work to .docx
Answer SheetInstructions You must show your work to .docx
 
A01
A01A01
A01
 
Synthetic Curves.pdf
Synthetic Curves.pdfSynthetic Curves.pdf
Synthetic Curves.pdf
 
C –FAQ:
C –FAQ:C –FAQ:
C –FAQ:
 
_4a Means-end analysis - data analysis.ppt
_4a Means-end analysis - data analysis.ppt_4a Means-end analysis - data analysis.ppt
_4a Means-end analysis - data analysis.ppt
 
P spice tutorialhkn
P spice tutorialhknP spice tutorialhkn
P spice tutorialhkn
 

Mesh Generation from Depth Maps

  • 1. Zachary Job 11/27/15 CS 532 Professor Mordohai HW6 NOTE: There’s a good chunk of code… I took an approach of listing what the code does in what file starting at what line. Problem 1: Since it sounded like drawing lines was not exactly essential, I made an informative text output. The algorithm is very simple and I checked a point so I don’t think it could mess up beyond a loss of precision here and there. I took to creating a bucket per vertex where faces where added if they had this vertex. Knowing calculating the normals for each connected face was needed, this solution seemed fit. The code…  Get the user specified file names – line 31 mgr.c  Enter the read ply function to load the data – line 40 mgr.c o Initialize base conditions – line 185 readPLY.c o Load the file to memory – line 119, 212 readPLY.c o Find the header for processing – line 221, 232 readPLY.c o Given there is no defined order for variables, set a list of offsets so – line 239 readPLY.c o Depending on which element was specified first, find the offset into the next element given order matters in my implementation – line 293 readPLY.c o Enter loadVerts to load the vertices – line 313 readPLY.c  Initialize the vertex list, the vertex face buckets, and the result list – line 34 readPLY.c, loadVerts  Get the current line or vertex data – line 44 readPLY.c, loadVerts  Break it into tokens – line 49 readPLY.c, loadVerts  Read the tokens into doubles with acceptable precision – line 60 readPLY.c, loadVerts  Use this loop to initialize the bucket data – line 66 o Enter loadFaces to load the faces – line 315 readPLY.c  Initialize the face list – line 96 readPLY.c, loadFaces  Get the current line or face data – line 103 readPLY.c, loadFace  Break it into tokens – line 108 readPLY.c, loadFaces
  • 2.  Assign the tokens as int representations of the tokens – line 116 readPLY.c, loadFaces  Enter calculateNormals to use the bucketed data to find the normal – line 47 mgr.c o Iterate every bucket or every vertex – line 30 calcualteNormals.c o Initialize the normals to be safe – line 32 calculateNormals.c o Iterate the bucket at the vertex index – line 37 calculateNormals.c o Find the normals with a point based formula – line 40, 49 calculateNormals.c o Produce the unit vector – line 54 calculateNormals.c o Average BUT do not get the unit vector for printing later – line 62 calculateNormals.c  Enter writeNormals to use all gathered information to make sensible output – line 54 mgr.c o Iterate each bucket – line 37 writeNorms.c o Write the vertex information including the normal and unit vector correction – line 44 writeNorms.c o Iterate the bucket to list the faces used – line 65 writeNorms.c o Write the buffer – line 77 writeNorms.c The results appear acceptable, and one was randomly selected and passed. I do not see any frailty in this code. It’s a basic algorithm and for what it seems everything works. The only fault would be if the wrong faces were bucketed which I can’t see how that would go wrong. This can be found in SRC_1/DATA/TXT/… Problem 2: My major delay here was actually that I was messing around and wanted to try an algorithm to push out from a line with a left right selector and enqueue line sides which did not have a face. It was just a heap of code I didn’t need to finish the assignment. I took to a “zipper” algorithm instead as it could be accomplished fast and made for easy debugging. This works on a super simple concept given we were allowed to drop vertices (which it did not create holes for this instance). Using the depth map… Iterate every column. Look from the top down for a new line, or pair of points. To finish it then would look for one point in the column to the right. The next start point for another line would then lock to the last point found for the initial line. For every two faces there could be closure to create a new face by drawing a line. As a vertex is used it too is projected and colored to ease writing the ply result soon after. The code…  Take the user input and jump to initData to setup the data – line 33 mgr.c o Initialize base cases – line 31, 37 initData.c o Ignore my shenanigans with checking for NULLs, I was getting frustrated with a memory leak – line 48 initData.c o Use grayToDouble pgm loader to get the user specified disparity – line 57 initData.c  No need to elaborate, this is a wrapper for your old ppm code slightly modified
  • 3. o Use pixelToDouble ppm loader to get the user specified colors – line 60 initData.c  No need to elaborate, this is a wrapper for your old ppm code slightly modified o Load the needed information eg focal information with acceptable precision – line 63, 70, 77 initData.c  Calculate the mesh, color the vertices, and project them all at once by calling calculateMesh – line 36 mgr.c o Allocate and set a list to the number of vertices in the previous column. This is used to find offsets into lists of elements – line 35, 38 calculateMesh.c o Initialize the now know amount of vertices – line 49 calculateMesh.c o Iterate each column to perform the zipper operation on it and its leftmost neighbor – line 58 calculateMesh.c o Get the offsets into the vertex list of the vertices per the used columns – line 61 calculateMesh.c o Iterate downwards on these two columns stopping when there are not enough or appropriate vertices to form a face – line 65 calculateMesh.c o Seek two vertices from the left column snapping v1 to either the first or last left vertex found (v2) – line 69 calculateMesh.c o Seek one vertex from the right column – line 86 calculateMesh.c o Allocate and set the new faces vertices – line 93, 98 calculateMesh.c (Note: confidence and intensity are debugging artifacts) o Project and color v1 if it is the first vertex selected in the left column – line 103 calculateMesh.c o Repeat regardless for v2 and v3 given with a match they must contain new vertices, but first adjust the line height given ++ skews the result by one in the for loops.. I could of handled that differently – line 128, 152 calculateMesh.c o If enough faces where found to create a new triangle by drawing between the right column matched vertices, generate additional faces. Do not work on the vertices given they had to have been manipulated already if they are part of existing faces – line 181 calculateMesh.c  Write a ply to display the newfound mesh using writePLY – line 52 mgr.c o Generate a header via using a fixed format and inserting the vertex and face counts – line 44 writePLY.c o Write the header – line 54 writePLY.c o For each vertex write out its needed information from a generated buffer – line 59 writePLY.c o For each face write out its needed information from a generated buffer – line 74 writePLY.c For this problem the results were visual so really any mistake was not hard to catch. It can be seen this algorithm has plenty that could be done better. Smoothing of sorts for one thing would be a good step. However it got the job done. There is significant stretching especially where the disparity
  • 4. could not show. Also, please note the coloring exists, however it is hard to notice given the edges are colored on the triangles. I didn’t think it necessary to rectify it because I have evidence of the texture. These can be found in SRC_2/DATA/SNAPS/… Proof of color, see the texture is apparent at this angle however faded due to stretching and the edge coloring Side one
  • 5. Side two, note the stretching from the lacking or more distant points Additional visuals from the top and bottom showcasing what could be and could not be captured by the depth map. They also show overall stretching Top Bottom
  • 6. Although messy, this is a functional representation of the blanket