Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
eb8728d7
Commit
eb8728d7
authored
Feb 02, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated cloud io functionality - removed dependency from VTK legacy
parent
63dbe66b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
313 additions
and
24 deletions
+313
-24
precomp.hpp
modules/viz/src/precomp.hpp
+1
-3
vizcore.cpp
modules/viz/src/vizcore.cpp
+2
-2
vtkCloudMatSink.cpp
modules/viz/src/vtk/vtkCloudMatSink.cpp
+16
-0
vtkCloudMatSink.h
modules/viz/src/vtk/vtkCloudMatSink.h
+9
-3
vtkOBJWriter.cpp
modules/viz/src/vtk/vtkOBJWriter.cpp
+33
-4
vtkOBJWriter.h
modules/viz/src/vtk/vtkOBJWriter.h
+17
-5
vtkXYZReader.cpp
modules/viz/src/vtk/vtkXYZReader.cpp
+107
-0
vtkXYZReader.h
modules/viz/src/vtk/vtkXYZReader.h
+80
-0
vtkXYZWriter.cpp
modules/viz/src/vtk/vtkXYZWriter.cpp
+33
-4
vtkXYZWriter.h
modules/viz/src/vtk/vtkXYZWriter.h
+15
-3
No files found.
modules/viz/src/precomp.hpp
View file @
eb8728d7
...
...
@@ -76,7 +76,6 @@
#include <vtkDoubleArray.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
#include <vtkPolyDataMapper.h>
#include <vtkDataSetMapper.h>
#include <vtkCellArray.h>
...
...
@@ -115,11 +114,9 @@
#include <vtkObjectFactory.h>
#include <vtkPolyDataAlgorithm.h>
#include <vtkMergeFilter.h>
#include <vtkDataSetWriter.h>
#include <vtkErrorCode.h>
#include <vtkPLYWriter.h>
#include <vtkSTLWriter.h>
#include <vtkSimplePointsReader.h>
#include <vtkPLYReader.h>
#include <vtkOBJReader.h>
#include <vtkSTLReader.h>
...
...
@@ -142,6 +139,7 @@
#include <vtk/vtkOBJWriter.h>
#include <vtk/vtkXYZWriter.h>
#include <vtk/vtkXYZReader.h>
#include <vtk/vtkCloudMatSink.h>
#include <vtk/vtkCloudMatSource.h>
#include <vtk/vtkTrajectorySource.h>
...
...
modules/viz/src/vizcore.cpp
View file @
eb8728d7
...
...
@@ -173,8 +173,8 @@ cv::Mat cv::viz::readCloud(const String& file, OutputArray colors, OutputArray n
vtkSmartPointer
<
vtkPolyDataAlgorithm
>
reader
;
if
(
extention
==
".xyz"
)
{
reader
=
vtkSmartPointer
<
vtk
SimplePoints
Reader
>::
New
();
vtk
SimplePoints
Reader
::
SafeDownCast
(
reader
)
->
SetFileName
(
file
.
c_str
());
reader
=
vtkSmartPointer
<
vtk
XYZ
Reader
>::
New
();
vtk
XYZ
Reader
::
SafeDownCast
(
reader
)
->
SetFileName
(
file
.
c_str
());
}
else
if
(
extention
==
".ply"
)
{
...
...
modules/viz/src/vtk/vtkCloudMatSink.cpp
View file @
eb8728d7
...
...
@@ -156,3 +156,19 @@ void cv::viz::vtkCloudMatSink::PrintSelf(ostream& os, vtkIndent indent)
os
<<
indent
<<
"Colors: "
<<
colors
.
needed
()
<<
"
\n
"
;
os
<<
indent
<<
"Normals: "
<<
normals
.
needed
()
<<
"
\n
"
;
}
int
cv
::
viz
::
vtkCloudMatSink
::
FillInputPortInformation
(
int
,
vtkInformation
*
info
)
{
info
->
Set
(
vtkAlgorithm
::
INPUT_REQUIRED_DATA_TYPE
(),
"vtkPolyData"
);
return
1
;
}
vtkPolyData
*
cv
::
viz
::
vtkCloudMatSink
::
GetInput
()
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
());
}
vtkPolyData
*
cv
::
viz
::
vtkCloudMatSink
::
GetInput
(
int
port
)
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
(
port
));
}
modules/viz/src/vtk/vtkCloudMatSink.h
View file @
eb8728d7
...
...
@@ -46,26 +46,32 @@
#define __vtkCloudMatSink_h
#include <opencv2/core/core.hpp>
#include <vtk
PolyData
Writer.h>
#include <vtkWriter.h>
namespace
cv
{
namespace
viz
{
class
vtkCloudMatSink
:
public
vtk
PolyData
Writer
class
vtkCloudMatSink
:
public
vtkWriter
{
public
:
static
vtkCloudMatSink
*
New
();
vtkTypeMacro
(
vtkCloudMatSink
,
vtk
PolyData
Writer
)
vtkTypeMacro
(
vtkCloudMatSink
,
vtkWriter
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
);
void
SetOutput
(
OutputArray
cloud
,
OutputArray
colors
=
noArray
(),
OutputArray
normals
=
noArray
(),
OutputArray
tcoords
=
noArray
());
// Description:
// Get the input to this writer.
vtkPolyData
*
GetInput
();
vtkPolyData
*
GetInput
(
int
port
);
protected
:
vtkCloudMatSink
();
~
vtkCloudMatSink
();
void
WriteData
();
int
FillInputPortInformation
(
int
port
,
vtkInformation
*
info
);
_OutputArray
cloud
,
colors
,
normals
,
tcoords
;
...
...
modules/viz/src/vtk/vtkOBJWriter.cpp
View file @
eb8728d7
...
...
@@ -54,7 +54,6 @@ cv::viz::vtkOBJWriter::vtkOBJWriter()
std
::
ofstream
fout
;
// only used to extract the default precision
this
->
DecimalPrecision
=
fout
.
precision
();
this
->
FileName
=
NULL
;
this
->
FileType
=
VTK_ASCII
;
}
cv
::
viz
::
vtkOBJWriter
::~
vtkOBJWriter
(){}
...
...
@@ -65,9 +64,22 @@ void cv::viz::vtkOBJWriter::WriteData()
if
(
!
input
)
return
;
std
::
ostream
*
outfilep
=
this
->
OpenVTKFile
();
if
(
!
outfilep
)
if
(
!
this
->
FileName
)
{
vtkErrorMacro
(
<<
"No FileName specified! Can't write!"
);
this
->
SetErrorCode
(
vtkErrorCode
::
NoFileNameError
);
return
;
}
vtkDebugMacro
(
<<
"Opening vtk file for writing..."
);
ostream
*
outfilep
=
new
ofstream
(
this
->
FileName
,
ios
::
out
);
if
(
outfilep
->
fail
())
{
vtkErrorMacro
(
<<
"Unable to open file: "
<<
this
->
FileName
);
this
->
SetErrorCode
(
vtkErrorCode
::
CannotOpenFileError
);
delete
outfilep
;
return
;
}
std
::
ostream
&
outfile
=
*
outfilep
;
...
...
@@ -224,7 +236,8 @@ void cv::viz::vtkOBJWriter::WriteData()
}
}
/* if (input->GetNumberOfStrips() > 0) */
this
->
CloseVTKFile
(
outfilep
);
vtkDebugMacro
(
<<
"Closing vtk file
\n
"
);
delete
outfilep
;
// Delete the file if an error occurred
if
(
this
->
ErrorCode
==
vtkErrorCode
::
OutOfDiskSpaceError
)
...
...
@@ -239,3 +252,19 @@ void cv::viz::vtkOBJWriter::PrintSelf(ostream& os, vtkIndent indent)
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"DecimalPrecision: "
<<
DecimalPrecision
<<
"
\n
"
;
}
int
cv
::
viz
::
vtkOBJWriter
::
FillInputPortInformation
(
int
,
vtkInformation
*
info
)
{
info
->
Set
(
vtkAlgorithm
::
INPUT_REQUIRED_DATA_TYPE
(),
"vtkPolyData"
);
return
1
;
}
vtkPolyData
*
cv
::
viz
::
vtkOBJWriter
::
GetInput
()
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
());
}
vtkPolyData
*
cv
::
viz
::
vtkOBJWriter
::
GetInput
(
int
port
)
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
(
port
));
}
modules/viz/src/vtk/vtkOBJWriter.h
View file @
eb8728d7
...
...
@@ -45,29 +45,41 @@
#ifndef __vtkOBJWriter_h
#define __vtkOBJWriter_h
#include <vtk
PolyData
Writer.h>
#include <vtkWriter.h>
namespace
cv
{
namespace
viz
{
class
vtkOBJWriter
:
public
vtk
PolyData
Writer
class
vtkOBJWriter
:
public
vtkWriter
{
public
:
static
vtkOBJWriter
*
New
();
vtkTypeMacro
(
vtkOBJWriter
,
vtk
PolyData
Writer
)
vtkTypeMacro
(
vtkOBJWriter
,
vtkWriter
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
);
vtkGetMacro
(
DecimalPrecision
,
int
);
vtkSetMacro
(
DecimalPrecision
,
int
);
vtkGetMacro
(
DecimalPrecision
,
int
)
vtkSetMacro
(
DecimalPrecision
,
int
)
// Description:
// Specify file name of data file to write.
vtkSetStringMacro
(
FileName
)
vtkGetStringMacro
(
FileName
)
// Description:
// Get the input to this writer.
vtkPolyData
*
GetInput
();
vtkPolyData
*
GetInput
(
int
port
);
protected
:
vtkOBJWriter
();
~
vtkOBJWriter
();
void
WriteData
();
int
FillInputPortInformation
(
int
port
,
vtkInformation
*
info
);
int
DecimalPrecision
;
char
*
FileName
;
private
:
vtkOBJWriter
(
const
vtkOBJWriter
&
);
// Not implemented.
...
...
modules/viz/src/vtk/vtkXYZReader.cpp
0 → 100644
View file @
eb8728d7
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#include "precomp.hpp"
namespace
cv
{
namespace
viz
{
vtkStandardNewMacro
(
vtkXYZReader
);
}}
cv
::
viz
::
vtkXYZReader
::
vtkXYZReader
()
{
this
->
FileName
=
0
;
this
->
SetNumberOfInputPorts
(
0
);
}
cv
::
viz
::
vtkXYZReader
::~
vtkXYZReader
()
{
this
->
SetFileName
(
0
);
}
void
cv
::
viz
::
vtkXYZReader
::
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
{
this
->
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"FileName: "
<<
(
this
->
FileName
?
this
->
FileName
:
"(none)"
)
<<
"
\n
"
;
}
int
cv
::
viz
::
vtkXYZReader
::
RequestData
(
vtkInformation
*
,
vtkInformationVector
**
,
vtkInformationVector
*
outputVector
)
{
// Make sure we have a file to read.
if
(
!
this
->
FileName
)
{
vtkErrorMacro
(
"A FileName must be specified."
);
return
0
;
}
// Open the input file.
ifstream
fin
(
this
->
FileName
);
if
(
!
fin
)
{
vtkErrorMacro
(
"Error opening file "
<<
this
->
FileName
);
return
0
;
}
// Allocate objects to hold points and vertex cells.
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>::
New
();
vtkSmartPointer
<
vtkCellArray
>
verts
=
vtkSmartPointer
<
vtkCellArray
>::
New
();
// Read points from the file.
vtkDebugMacro
(
"Reading points from file "
<<
this
->
FileName
);
double
x
[
3
];
while
(
fin
>>
x
[
0
]
>>
x
[
1
]
>>
x
[
2
])
{
vtkIdType
id
=
points
->
InsertNextPoint
(
x
);
verts
->
InsertNextCell
(
1
,
&
id
);
}
vtkDebugMacro
(
"Read "
<<
points
->
GetNumberOfPoints
()
<<
" points."
);
// Store the points and cells in the output data object.
vtkPolyData
*
output
=
vtkPolyData
::
GetData
(
outputVector
);
output
->
SetPoints
(
points
);
output
->
SetVerts
(
verts
);
return
1
;
}
modules/viz/src/vtk/vtkXYZReader.h
0 → 100644
View file @
eb8728d7
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
//M*/
#ifndef __vtkXYZReader_h
#define __vtkXYZReader_h
#include "vtkPolyDataAlgorithm.h"
namespace
cv
{
namespace
viz
{
class
vtkXYZReader
:
public
vtkPolyDataAlgorithm
{
public
:
static
vtkXYZReader
*
New
();
vtkTypeMacro
(
vtkXYZReader
,
vtkPolyDataAlgorithm
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
);
// Description:
// Set/Get the name of the file from which to read points.
vtkSetStringMacro
(
FileName
)
vtkGetStringMacro
(
FileName
)
protected
:
vtkXYZReader
();
~
vtkXYZReader
();
char
*
FileName
;
int
RequestData
(
vtkInformation
*
,
vtkInformationVector
**
,
vtkInformationVector
*
);
private
:
vtkXYZReader
(
const
vtkXYZReader
&
);
// Not implemented.
void
operator
=
(
const
vtkXYZReader
&
);
// Not implemented.
};
}
}
#endif
modules/viz/src/vtk/vtkXYZWriter.cpp
View file @
eb8728d7
...
...
@@ -61,10 +61,22 @@ void cv::viz::vtkXYZWriter::WriteData()
if
(
!
input
)
return
;
// OpenVTKFile() will report any errors that happen
ostream
*
outfilep
=
this
->
OpenVTKFile
();
if
(
!
outfilep
)
if
(
!
this
->
FileName
)
{
vtkErrorMacro
(
<<
"No FileName specified! Can't write!"
);
this
->
SetErrorCode
(
vtkErrorCode
::
NoFileNameError
);
return
;
}
vtkDebugMacro
(
<<
"Opening vtk file for writing..."
);
ostream
*
outfilep
=
new
ofstream
(
this
->
FileName
,
ios
::
out
);
if
(
outfilep
->
fail
())
{
vtkErrorMacro
(
<<
"Unable to open file: "
<<
this
->
FileName
);
this
->
SetErrorCode
(
vtkErrorCode
::
CannotOpenFileError
);
delete
outfilep
;
return
;
}
ostream
&
outfile
=
*
outfilep
;
...
...
@@ -76,7 +88,8 @@ void cv::viz::vtkXYZWriter::WriteData()
}
// Close the file
this
->
CloseVTKFile
(
outfilep
);
vtkDebugMacro
(
<<
"Closing vtk file
\n
"
);
delete
outfilep
;
// Delete the file if an error occurred
if
(
this
->
ErrorCode
==
vtkErrorCode
::
OutOfDiskSpaceError
)
...
...
@@ -86,8 +99,24 @@ void cv::viz::vtkXYZWriter::WriteData()
}
}
int
cv
::
viz
::
vtkXYZWriter
::
FillInputPortInformation
(
int
,
vtkInformation
*
info
)
{
info
->
Set
(
vtkAlgorithm
::
INPUT_REQUIRED_DATA_TYPE
(),
"vtkPolyData"
);
return
1
;
}
void
cv
::
viz
::
vtkXYZWriter
::
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
)
{
this
->
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"DecimalPrecision: "
<<
this
->
DecimalPrecision
<<
"
\n
"
;
}
vtkPolyData
*
cv
::
viz
::
vtkXYZWriter
::
GetInput
()
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
());
}
vtkPolyData
*
cv
::
viz
::
vtkXYZWriter
::
GetInput
(
int
port
)
{
return
vtkPolyData
::
SafeDownCast
(
this
->
Superclass
::
GetInput
(
port
));
}
modules/viz/src/vtk/vtkXYZWriter.h
View file @
eb8728d7
...
...
@@ -45,29 +45,41 @@
#ifndef __vtkXYZWriter_h
#define __vtkXYZWriter_h
#include "vtk
PolyData
Writer.h"
#include "vtkWriter.h"
namespace
cv
{
namespace
viz
{
class
vtkXYZWriter
:
public
vtk
PolyData
Writer
class
vtkXYZWriter
:
public
vtkWriter
{
public
:
static
vtkXYZWriter
*
New
();
vtkTypeMacro
(
vtkXYZWriter
,
vtk
PolyData
Writer
)
vtkTypeMacro
(
vtkXYZWriter
,
vtkWriter
)
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
);
vtkGetMacro
(
DecimalPrecision
,
int
)
vtkSetMacro
(
DecimalPrecision
,
int
)
// Description:
// Specify file name of data file to write.
vtkSetStringMacro
(
FileName
)
vtkGetStringMacro
(
FileName
)
// Description:
// Get the input to this writer.
vtkPolyData
*
GetInput
();
vtkPolyData
*
GetInput
(
int
port
);
protected
:
vtkXYZWriter
();
~
vtkXYZWriter
(){}
void
WriteData
();
int
FillInputPortInformation
(
int
port
,
vtkInformation
*
info
);
int
DecimalPrecision
;
char
*
FileName
;
private
:
vtkXYZWriter
(
const
vtkXYZWriter
&
);
// Not implemented.
...
...
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