Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/opencv_contrib.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modules/structured_light/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
set(the_description "Structured Light API")
ocv_define_module(structured_light opencv_core opencv_imgproc opencv_calib3d opencv_phase_unwrapping OPTIONAL opencv_viz WRAP python java objc)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary changes from PR

55 changes: 55 additions & 0 deletions modules/structured_light/images/calibration_result.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modules/structured_light/images

Perhaps should go into modules/structured_light/samples/data instead.

<opencv_storage>
<img_shape type_id="opencv-matrix">
<rows>2</rows>
<cols>1</cols>
<dt>d</dt>
<data>
720. 1280.</data></img_shape>
<rms>8.9865323037520906e+00</rms>
<cam_int type_id="opencv-matrix">
<rows>3</rows>
<cols>3</cols>
<dt>d</dt>
<data>
2.2902176176240550e+03 0. 4.7760365772945374e+02 0.
2.0789910149720636e+03 5.9663906901935786e+02 0. 0. 1.</data></cam_int>
<cam_dist type_id="opencv-matrix">
<rows>1</rows>
<cols>5</cols>
<dt>d</dt>
<data>
2.2272502988720682e+00 6.2041480268790341e+00 5.1365359803581978e-01
-1.1065215615966861e-01 -4.8897144273472620e+01</data></cam_dist>
<proj_int type_id="opencv-matrix">
<rows>3</rows>
<cols>3</cols>
<dt>d</dt>
<data>
1.4173607712558548e+03 0. 5.1752307732265035e+02 0.
1.3963061950617591e+03 7.1503556186206947e+02 0. 0. 1.</data></proj_int>
<proj_dist type_id="opencv-matrix">
<rows>1</rows>
<cols>5</cols>
<dt>d</dt>
<data>
1.4490791728765842e-01 -7.4856581249561327e-01
-9.0651830613910390e-03 -3.4131371258920178e-02
1.3733497765243312e+00</data></proj_dist>
<roration type_id="opencv-matrix">
<rows>3</rows>
<cols>3</cols>
<dt>d</dt>
<data>
9.9215888102252536e-01 -9.4771920438436966e-03
1.2462318259093863e-01 1.0446695919745458e-02 9.9992002393776458e-01
-7.1282727683994072e-03 -1.2454565970956474e-01
8.3742796265969446e-03 9.9217853740556439e-01</data></roration>
<translation type_id="opencv-matrix">
<rows>3</rows>
<cols>1</cols>
<dt>d</dt>
<data>
-3.5484301147652934e+02 2.2059644511693236e+02
-1.3115183374509279e+03</data></translation>
</opencv_storage>
Binary file added modules/structured_light/images/hf_phase0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_phase1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_phase2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_phase3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_ref0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_ref1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_ref2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/hf_ref3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_phase0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_phase1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_phase2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_phase3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_ref0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_ref1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_ref2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/lf_ref3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/structured_light/images/o_1000000.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000001.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000002.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000003.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000005.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000006.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000007.bmp
Binary file not shown.
Binary file added modules/structured_light/images/o_1000008.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions modules/structured_light/include/opencv2/structured_light.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#include "opencv2/structured_light/structured_light.hpp"
#include "opencv2/structured_light/graycodepattern.hpp"
#include "opencv2/structured_light/sinusoidalpattern.hpp"
#include "opencv2/structured_light/slmono_calibration.hpp"
#include "opencv2/structured_light/slmono_utils.hpp"
#include "opencv2/structured_light/slmono.hpp"

/** @defgroup structured_light Structured Light API

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.


#ifndef OPENCV_structured_light_HPP
#define OPENCV_structured_light_HPP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capital letters
add _SLMONO_


#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>

namespace cv{
namespace structured_light{
class CV_EXPORTS StructuredLightMono : public virtual Algorithm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

virtual

Do we really need this here?

{
public:

StructuredLightMono(Size img_size, int patterns, int stripes_number, std::string algs_type)
{
projector_size = img_size;
pattern_num = patterns;
alg_type = algs_type;
stripes_num = stripes_number;
}

//generate patterns for projecting
void generatePatterns(OutputArrayOfArrays patterns, float stripes_angle);

//project patterns and capture with camera
//CV_WRAP
// void captureImages(InputArrayOfArrays patterns, OutputArrayOfArrays refs, OutputArrayOfArrays imgs, bool isCaptureRefs = true);

//main phase unwrapping algorithm
void unwrapPhase(InputOutputArrayOfArrays refs, InputOutputArrayOfArrays imgs, OutputArray out);

//read references and phases from file
//CV_WRAP
// void readImages(std::vector<std::string> refs_files, std::vector<std::string> imgs_files, OutputArrayOfArrays refs, OutputArrayOfArrays imgs);

private:

//size of the image for whole algorithm
Size projector_size;

//number of pattern used in SL algorithm starting from 3
int pattern_num;

//number of stripes in the image pattern
int stripes_num;

//PCG or TPU
std::string alg_type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string

enum?


//remove shadows from images
void removeShadows(InputOutputArrayOfArrays refs, InputOutputArrayOfArrays imgs);

//phase unwrapping with PCG algorithm based on DCT
void computePhasePCG(InputOutputArrayOfArrays refs, InputOutputArrayOfArrays imgs, OutputArray out);

//standart temporal unwrap algorithm
void computePhaseTPU(InputOutputArrayOfArrays refs, InputOutputArrayOfArrays imgs, OutputArray out);
};

}} // cv::structured_light::

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

#ifndef OPENCV_structured_light_mono_calibration_HPP
#define OPENCV_structured_light_mono_calibration_HPP

#include <opencv2/core.hpp>
//#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/calib3d.hpp>

using namespace std;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using namespace is not allowed in OpenCV public headers (to avoid breaking of users code)


namespace cv{
namespace structured_light{

enum calibrationPattern{CHESSBOARD, CIRCLES_GRID, ASYMETRIC_CIRCLES_GRID};

struct Settings
{
Settings();
int patternType;
Size patternSize;
Size subpixelSize;
Size imageSize;
float squareSize;
int nbrOfFrames;
};

void loadSettings(String path, Settings &sttngs);

void createObjectPoints( InputArrayOfArrays patternCorners, Size patternSize, float squareSize, int patternType );

void createProjectorObjectPoints(InputArrayOfArrays patternCorners, Size patternSize, float squareSize, int patternType );

double calibrate(InputArrayOfArrays objPoints, InputArrayOfArrays imgPoints, InputOutputArray cameraMatrix, InputOutputArray distCoeffs, OutputArrayOfArrays r, OutputArrayOfArrays t, Size imgSize );

void fromCamToWorld(InputArray cameraMatrix, InputArrayOfArrays rV, InputArrayOfArrays tV, InputArrayOfArrays imgPoints, OutputArrayOfArrays worldPoints );

void saveCalibrationResults( String path, InputArray camK, InputArray camDistCoeffs, InputArray projK, InputArray projDistCoeffs, InputArray fundamental);

void saveCalibrationData( String path, InputArrayOfArrays T1, InputArrayOfArrays T2,InputArrayOfArrays ptsProjCam, InputArrayOfArrays ptsProjProj, InputArrayOfArrays ptsProjCamN, InputArrayOfArrays ptsProjProjN);

void normalize(InputArray pts, const int& dim, InputOutputArray normpts, OutputArray T);

void fromVectorToMat(InputArrayOfArrays v, OutputArray pts);

void fromMatToVector(InputArray pts, OutputArrayOfArrays v);

void loadCalibrationData(string filename, OutputArray cameraIntrinsic, OutputArray projectorIntrinsic, OutputArray cameraDistortion, OutputArray projectorDistortion, OutputArray rotation, OutputArray translation);

void distortImage(InputArray input, InputArray camMat, InputArray dist, OutputArray output);

}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

#ifndef OPENCV_structured_light_mono_utils_HPP
#define OPENCV_structured_light_mono_utils_HPP

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>

using namespace std;

namespace cv{
namespace structured_light{

//compute atan2 for object and reference images
void computeAtanDiff(InputOutputArrayOfArrays src, OutputArray dst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid indentation in namespaces.


/**
Phase unwrapping algorithm based on PCG.
**/
void unwrapPCG(InputArray img, OutputArray out, Size imgSize);

/**
Phase unwrapping algorithm based on TPU.
**/
void unwrapTPU(InputArray phase1, InputArray phase2, OutputArray out, int scale);

void lowPassFilter(InputArray img, OutputArray out, int filterSize = 30);
void highPassFilter(InputArray img, OutputArray out, int filterSize = 30);

void calibrateCameraProjector();
void distortPatterns();
void undistortPatterns();

void savePointCloud(InputArray phase, string filename); //filter image from outliers and save as txt

}
}

#endif
Loading