33 #include <Base/Common/W32Compat.hh>
34 #include <Base/Geometry/HomgPoint2D.hh>
35 #include <Geometry/Conic2D.hh>
36 #include <Base/Image/Image.hh>
37 #include <Base/Image/ImageIO.hh>
38 #include <Geometry/Quadric3D.hh>
39 #include <Geometry/PMatrix.hh>
49 cout <<
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ExampleConic $$$$$$$$$$$$$$$$$$$$$$"
56 Conic.
SetEllipse(C, 35.0 *M_PI/180.0, 180.0, 70);
59 for (
unsigned int i=0; i<15; i++) {
62 cout <<
"Circle center is now at "<<C2<<endl;
64 else cout <<
"No Intersection !"<<endl;
67 Circle.
Draw(TestImage);
68 Conic.
Draw(TestImage);
70 sprintf(filename,
"testimage%03d",i);
88 #ifdef BIASASSERT_ISACTIVE
92 BIASASSERT(resPCA == 0);
93 cout <<
"Singular values of Cov are "<<S<<endl;
109 for (
unsigned int l=0; l<3; l++) {
110 G[l] += sqrt(S[0]) * G_0[l] * GAUSS3D_CONFIDENCE_99_PERCENT;
111 H[l] += sqrt(S[1]) * H_0[l] * GAUSS3D_CONFIDENCE_99_PERCENT;
112 I[l] += sqrt(S[2]) * I_0[l] * GAUSS3D_CONFIDENCE_99_PERCENT;
120 Quadric3D TestQ(QC, Cov, GAUSS3D_CONFIDENCE_99_PERCENT );
121 cout <<
"Quadric is "<< TestQ << endl;
124 cout <<
"Conic is "<<(TestC.
IsEllipse()?
"an ":
"no ")
125 <<
"ellipse: "<< TestC << endl;
129 for (
int u=0; u<4; u++) {
131 case 0:pPoint = &QC;
break;
132 case 1:pPoint = &G;
break;
133 case 2:pPoint = &H;
break;
134 case 3:pPoint = &I;
break;
135 default:BIASERR(
"Debug loop out of range !");
137 Projection = P_current * (*pPoint);
140 double Location = TestQ.LocatePoint(*pPoint);
141 cout <<
"Computing point on quadric ! Location is "<<Location
142 <<
", pointindex[u] is "<<u<<endl;;
145 if (Location>DBL_EPSILON) {
146 BIASERR(
"Covariance ellipsoid projection: Point["<<u<<
"] not in"
147 <<
" projection area !"<<endl<<(*pPoint)<<
" -> "
148 << Projection<<endl<<
" Location is "<<Location
149 <<
", Conic is "<<TestC
150 <<
", Covariance matrix is "<< Cov
151 <<
" sigmas are "<<S[0]<<
" "<<S[1]<<
" "<<S[2]<<endl
152 <<
"Ellipsoid center is at "<< QC);
155 double dAngle, radius_a, radius_b;
157 BIASERR(
"Ellipse at "<<Center<<
" with "<<radius_a<<
"/"<<radius_b
158 <<
" rotated by "<<dAngle/M_PI*180.0
159 <<
" degrees counterclockwise.");
161 BIASERR(
"Error retrieving explicit ellipse parameters.");
164 BIASERR(
"Projection is NO ellipse !");
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
bool GetEllipseParameters(HomgPoint2D &Center, double &dAngle, double &radius_a, double &radius_b) const
computes explicit ellipse representation
bool IsEllipse() const
check whether this conic is an ellipse
int GetPCA(Vector3< COVMATRIX3X3_TYPE > &S, Matrix3x3< COVMATRIX3X3_TYPE > &VT)
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
void SetEllipse(const HomgPoint2D &Center, const double &dAngle, const double &radius_a, const double &radius_b)
construct an ellipse with explicit parameters
A quadric as a 4x4 matrix describing a surface in 3d projective space defined by a quadratic equation...
double LocatePoint(const HomgPoint2D &point2D) const
determines if the point is inside/on/outside the conic
This class hides the underlying projection model, like projection matrix, spherical camera...
void SetIdentity()
set the elements of this matrix to the matrix 1 0 0 0 0 1 0 0 0 0 1 0 which is no strict identity (!)...
int GetInverse(Matrix3x3< T > &inv) const
Matrix inversion: inverts this and stores resulty in argument inv.
class for 3x3 covariance matrices
void SetQuadricProjection(const Quadric3D &Q, const PMatrix &P, bool UseSVD=false)
constructs a conic that is a projection of the quadric Q using camera matrix P
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
bool IntersectsCircle(const HomgPoint2D &C, double Radius) const
returns true if the given Conic intersects with the circle of radius Radius around point C...
void Draw(Image< unsigned char > &img) const
draws conic into an image using a brute force method
describes a projective 3D -> 2D mapping in homogenous coordinates
A 3x3 matrix representing a conic (cone/plane intersection)
T Normalize()
divide this by biggest absolute entry, returns biggest entry
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...