 |
OpenCV
4.5.1
Open Source Computer Vision
|
An example using the cv::linearPolar and cv::logPolar operations
#include <iostream>
int main( int argc, char** argv )
{
Mat log_polar_img, lin_polar_img, recovered_log_polar, recovered_lin_polar_img;
CommandLineParser parser(argc, argv,
"{@input|0| camera device number or video file path}");
parser.
about(
"\nThis program illustrates usage of Linear-Polar and Log-Polar image transforms\n");
std::string arg = parser.
get<std::string>(
"@input");
if( arg.size() == 1 && isdigit(arg[0]) )
capture.
open( arg[0] -
'0' );
else
{
fprintf(stderr,"Could not initialize capturing...\n");
return -1;
}
for(;;)
{
capture >> src;
if(src.empty() )
break;
Point2f center( (
float)src.cols / 2, (
float)src.rows / 2 );
double maxRadius = 0.7*
min(center.
y, center.
x);
#if 0 //deprecated
double M = frame.cols /
log(maxRadius);
logPolar(frame, log_polar_img, center, M, flags);
linearPolar(frame, lin_polar_img, center, maxRadius, flags);
#endif
dst = log_polar_img;
else
dst = lin_polar_img;
angleRad = phi / Kangle;
{
}
else
{
double Klin = dst.
cols / maxRadius;
}
imshow(
"Log-Polar", log_polar_img);
imshow(
"Linear-Polar", lin_polar_img);
imshow(
"Recovered Linear-Polar", recovered_lin_polar_img );
imshow(
"Recovered Log-Polar", recovered_log_polar );
break;
}
return 0;
}
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition: mat.hpp:2092
Quat< T > cos(const Quat< T > &q)
void moveWindow(const String &winname, int x, int y)
Moves the window to the specified position.
T get(const String &name, bool space_delete=true) const
Access arguments by name.
Definition: utility.hpp:855
Class for video capturing from video files, image sequences or cameras.
Definition: videoio.hpp:628
int waitKey(int delay=0)
Waits for a pressed key.
_Tp y
y coordinate of the point
Definition: types.hpp:187
_Tp x
x coordinate of the point
Definition: types.hpp:186
Quat< T > sin(const Quat< T > &q)
#define CV_2PI
Definition: cvdef.h:355
softfloat min(const softfloat &a, const softfloat &b)
Min and Max functions.
Definition: softfloat.hpp:437
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Quat< T > log(const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
Size2i Size
Definition: types.hpp:347
int cols
Definition: mat.hpp:2092
MatSize size
Definition: mat.hpp:2114
void magnitude(InputArray x, InputArray y, OutputArray magnitude)
Calculates the magnitude of 2D vectors.
virtual bool isOpened() const
Returns true if video capturing has been initialized already.
int cvRound(double value)
Rounds floating-point number to the nearest integer.
Definition: fast_math.hpp:197
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
Scalar_< double > Scalar
Definition: types.hpp:669
Point2i Point
Definition: types.hpp:194
n-dimensional dense array class
Definition: mat.hpp:798
cv::String findFileOrKeep(const cv::String &relative_path, bool silentMode=false)
Definition: utility.hpp:1156
Quat< T > exp(const Quat< T > &q)
void about(const String &message)
Set the about message.
Designed for command line parsing.
Definition: utility.hpp:789
@ WINDOW_AUTOSIZE
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:188
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:52
void printMessage() const
Print help message.
void drawMarker(InputOutputArray img, Point position, const Scalar &color, int markerType=MARKER_CROSS, int markerSize=20, int thickness=1, int line_type=8)
Draws a marker on a predefined position in an image.
virtual bool open(const String &filename, int apiPreference=CAP_ANY)
Opens a video file or a capturing device or an IP video stream for video capturing.