Commit 565bcab2 authored by berak's avatar berak

remove viz/vk dependancy

parent 4f860dcf
set(the_description "Structured Light API") set(the_description "Structured Light API")
ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_viz opencv_rgbd) ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd OPTIONAL opencv_viz)
\ No newline at end of file
...@@ -45,7 +45,12 @@ ...@@ -45,7 +45,12 @@
#include <opencv2/calib3d.hpp> #include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/structured_light.hpp> #include <opencv2/structured_light.hpp>
#include <opencv2/opencv_modules.hpp>
// (if you did not build the opencv_viz module, you will only see the disparity images)
#ifdef HAVE_OPENCV_VIZ
#include <opencv2/viz.hpp> #include <opencv2/viz.hpp>
#endif
using namespace std; using namespace std;
using namespace cv; using namespace cv;
...@@ -73,13 +78,13 @@ static bool readStringList( const string& filename, vector<string>& l ) ...@@ -73,13 +78,13 @@ static bool readStringList( const string& filename, vector<string>& l )
if( !fs.isOpened() ) if( !fs.isOpened() )
{ {
cerr << "failed to open " << filename << endl; cerr << "failed to open " << filename << endl;
return -1; return false;
} }
FileNode n = fs.getFirstTopLevelNode(); FileNode n = fs.getFirstTopLevelNode();
if( n.type() != FileNode::SEQ ) if( n.type() != FileNode::SEQ )
{ {
cerr << "cam 1 images are not a sequence! FAIL" << endl; cerr << "cam 1 images are not a sequence! FAIL" << endl;
return -1; return false;
} }
FileNodeIterator it = n.begin(), it_end = n.end(); FileNodeIterator it = n.begin(), it_end = n.end();
...@@ -92,7 +97,7 @@ static bool readStringList( const string& filename, vector<string>& l ) ...@@ -92,7 +97,7 @@ static bool readStringList( const string& filename, vector<string>& l )
if( n.type() != FileNode::SEQ ) if( n.type() != FileNode::SEQ )
{ {
cerr << "cam 2 images are not a sequence! FAIL" << endl; cerr << "cam 2 images are not a sequence! FAIL" << endl;
return -1; return false;
} }
it = n.begin(), it_end = n.end(); it = n.begin(), it_end = n.end();
...@@ -104,7 +109,7 @@ static bool readStringList( const string& filename, vector<string>& l ) ...@@ -104,7 +109,7 @@ static bool readStringList( const string& filename, vector<string>& l )
if( l.size() % 2 != 0 ) if( l.size() % 2 != 0 )
{ {
cout << "Error: the image list contains odd (non-even) number of elements\n"; cout << "Error: the image list contains odd (non-even) number of elements\n";
return -1; return false;
} }
return true; return true;
} }
...@@ -133,8 +138,8 @@ int main( int argc, char** argv ) ...@@ -133,8 +138,8 @@ int main( int argc, char** argv )
if( argc == 7 ) if( argc == 7 )
{ {
// If passed, setting the white and black threshold, otherwise using default values // If passed, setting the white and black threshold, otherwise using default values
white_thresh = parser.get<size_t>( 4 ); white_thresh = parser.get<unsigned>( 4 );
black_thresh = parser.get<size_t>( 5 ); black_thresh = parser.get<unsigned>( 5 );
graycode->setWhiteThreshold( white_thresh ); graycode->setWhiteThreshold( white_thresh );
graycode->setBlackThreshold( black_thresh ); graycode->setBlackThreshold( black_thresh );
...@@ -271,6 +276,7 @@ int main( int argc, char** argv ) ...@@ -271,6 +276,7 @@ int main( int argc, char** argv )
resize( thresholded_disp, dst, Size( 640, 480 ) ); resize( thresholded_disp, dst, Size( 640, 480 ) );
imshow( "threshold disp otsu", dst ); imshow( "threshold disp otsu", dst );
#ifdef HAVE_OPENCV_VIZ
// Apply the mask to the point cloud // Apply the mask to the point cloud
Mat pointcloud_tresh, color_tresh; Mat pointcloud_tresh, color_tresh;
pointcloud.copyTo( pointcloud_tresh, thresholded_disp ); pointcloud.copyTo( pointcloud_tresh, thresholded_disp );
...@@ -283,8 +289,10 @@ int main( int argc, char** argv ) ...@@ -283,8 +289,10 @@ int main( int argc, char** argv )
myWindow.showWidget( "pointcloud", viz::WCloud( pointcloud_tresh, color_tresh ) ); myWindow.showWidget( "pointcloud", viz::WCloud( pointcloud_tresh, color_tresh ) );
myWindow.showWidget( "text2d", viz::WText( "Point cloud", Point(20, 20), 20, viz::Color::green() ) ); myWindow.showWidget( "text2d", viz::WText( "Point cloud", Point(20, 20), 20, viz::Color::green() ) );
myWindow.spin(); myWindow.spin();
#endif // HAVE_OPENCV_VIZ
} }
waitKey(); waitKey();
return 0; return 0;
} }
\ No newline at end of file
...@@ -89,11 +89,11 @@ class CV_EXPORTS_W GrayCodePattern_Impl : public GrayCodePattern ...@@ -89,11 +89,11 @@ class CV_EXPORTS_W GrayCodePattern_Impl : public GrayCodePattern
// Number between 0-255 that represents the minimum brightness difference // Number between 0-255 that represents the minimum brightness difference
// between the fully illuminated (white) and the non - illuminated images (black) // between the fully illuminated (white) and the non - illuminated images (black)
int blackThreshold; size_t blackThreshold;
// Number between 0-255 that represents the minimum brightness difference // Number between 0-255 that represents the minimum brightness difference
// between the gray-code pattern and its inverse images // between the gray-code pattern and its inverse images
int whiteThreshold; size_t whiteThreshold;
// Computes the required number of pattern images, allocating the pattern vector // Computes the required number of pattern images, allocating the pattern vector
void computeNumberOfPatternImages(); void computeNumberOfPatternImages();
...@@ -220,8 +220,8 @@ bool GrayCodePattern_Impl::decode( InputArrayOfArrays patternImages, OutputArray ...@@ -220,8 +220,8 @@ bool GrayCodePattern_Impl::decode( InputArrayOfArrays patternImages, OutputArray
std::vector<Mat> shadowMasks; std::vector<Mat> shadowMasks;
computeShadowMasks( blackImages, whitheImages, shadowMasks ); computeShadowMasks( blackImages, whitheImages, shadowMasks );
size_t cam_width = acquired_pattern[0][0].cols; int cam_width = acquired_pattern[0][0].cols;
size_t cam_height = acquired_pattern[0][0].rows; int cam_height = acquired_pattern[0][0].rows;
Point projPixel; Point projPixel;
...@@ -233,9 +233,9 @@ bool GrayCodePattern_Impl::decode( InputArrayOfArrays patternImages, OutputArray ...@@ -233,9 +233,9 @@ bool GrayCodePattern_Impl::decode( InputArrayOfArrays patternImages, OutputArray
for( size_t k = 0; k < acquired_pattern.size(); k++ ) for( size_t k = 0; k < acquired_pattern.size(); k++ )
{ {
camsPixels[k].resize( params.height * params.width ); camsPixels[k].resize( params.height * params.width );
for( size_t i = 0; i < cam_width; i++ ) for( int i = 0; i < cam_width; i++ )
{ {
for( size_t j = 0; j < cam_height; j++ ) for( int j = 0; j < cam_height; j++ )
{ {
//if the pixel is not shadowed, reconstruct //if the pixel is not shadowed, reconstruct
if( shadowMasks[k].at<uchar>( j, i ) ) if( shadowMasks[k].at<uchar>( j, i ) )
...@@ -345,10 +345,10 @@ void GrayCodePattern_Impl::computeShadowMasks( InputArrayOfArrays blackImages, I ...@@ -345,10 +345,10 @@ void GrayCodePattern_Impl::computeShadowMasks( InputArrayOfArrays blackImages, I
{ {
for( int j = 0; j < cam_height; j++ ) for( int j = 0; j < cam_height; j++ )
{ {
uchar white = whiteImages_[k].at<uchar>( Point( i, j ) ); double white = whiteImages_[k].at<uchar>( Point( i, j ) );
uchar black = blackImages_[k].at<uchar>( Point( i, j ) ); double black = blackImages_[k].at<uchar>( Point( i, j ) );
if( white - black > blackThreshold ) if( abs(white - black) > blackThreshold )
{ {
shadowMasks_[k].at<uchar>( Point( i, j ) ) = ( uchar ) 1; shadowMasks_[k].at<uchar>( Point( i, j ) ) = ( uchar ) 1;
} }
...@@ -472,4 +472,4 @@ Ptr<GrayCodePattern> GrayCodePattern::create( const GrayCodePattern::Params& par ...@@ -472,4 +472,4 @@ Ptr<GrayCodePattern> GrayCodePattern::create( const GrayCodePattern::Params& par
} }
} }
} }
\ No newline at end of file
...@@ -73,12 +73,12 @@ void CV_GetProjPixelTest::run( int ) ...@@ -73,12 +73,12 @@ void CV_GetProjPixelTest::run( int )
Point projPixel; Point projPixel;
size_t image_width = pattern[0].cols; int image_width = pattern[0].cols;
size_t image_height = pattern[0].rows; int image_height = pattern[0].rows;
for( size_t i = 0; i < image_width; i++ ) for( int i = 0; i < image_width; i++ )
{ {
for( size_t j = 0; j < image_height; j++ ) for( int j = 0; j < image_height; j++ )
{ {
//for a (x,y) pixel of the camera returns the corresponding projector pixel //for a (x,y) pixel of the camera returns the corresponding projector pixel
bool error = graycode->getProjPixel( pattern, i, j, projPixel ); bool error = graycode->getProjPixel( pattern, i, j, projPixel );
...@@ -97,4 +97,4 @@ TEST( GrayCodePattern, getProjPixel ) ...@@ -97,4 +97,4 @@ TEST( GrayCodePattern, getProjPixel )
{ {
CV_GetProjPixelTest test; CV_GetProjPixelTest test;
test.safe_run(); test.safe_run();
} }
\ No newline at end of file
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <opencv2/highgui.hpp> #include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp> #include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/viz.hpp>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
...@@ -360,4 +359,4 @@ TEST( GrayCodePattern, plane_reconstruction ) ...@@ -360,4 +359,4 @@ TEST( GrayCodePattern, plane_reconstruction )
{ {
CV_PlaneTest test; CV_PlaneTest test;
test.safe_run(); test.safe_run();
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment