Skip to content

Commit

Permalink
v2.3 final edits
Browse files Browse the repository at this point in the history
  • Loading branch information
skramm committed Jun 18, 2021
1 parent 3556a71 commit 72a1e93
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 39 deletions.
3 changes: 1 addition & 2 deletions docs/homog2d_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See [Release page](https://github.com/skramm/homog2d/releases).
- Licence change to MPLv2
- remplaced `HOMOG2D_SAFE_MODE` with `HOMOG2D_NOCHECKS`, so that checking is enabled by default.

- Next release v2.3 (current master branch):
- [v2.3](https://github.com/skramm/homog2d/releases/tag/v2.3), released on 2021-06-18
- all computations are now done using default numerical type `HOMOG2D_INUMTYPE`
- added `buildFrom4Points()` to Homography class
- added templated conversion free functions and member function to Opencv point types
Expand All @@ -38,7 +38,6 @@ See [Release page](https://github.com/skramm/homog2d/releases).




### Footnotes

[(1)](#paedfapol)
Expand Down
42 changes: 7 additions & 35 deletions misc/demo_opencv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ struct Data
{
cv::setMouseCallback( win1, mouse_CB, this );
}

int nbPts() const
{
return (int)vpt.size();
Expand All @@ -82,12 +81,6 @@ struct Data
cv::imshow( win1, img );
}

void moveSelectedPoint()
{
if( selected != -1 )
vpt.at(selected) = pt_mouse;
}

void drawLines()
{
for( int i=0; i<nbPts(); i++ )
Expand All @@ -107,7 +100,6 @@ struct Data
lC.draw( img, CvDrawParams().setColor( 50, 150, 0) );
lD.draw( img, CvDrawParams().setColor( 150, 0, 50) );
}

};


Expand All @@ -132,14 +124,21 @@ checkSelected( int event, int x, int y, std::function<void(void*)> action, std::
break;

case CV_EVENT_LBUTTONDOWN:
data.selected = -1;
for( int i=0; i<data.nbPts(); i++ )
if( data.pt_mouse.distTo( data.vpt[i]) < 10 ) // if mouse is less than 10 pixel away
data.selected = i;
if( data.selected != -1 )
data.vpt[data.selected].draw( data.img, CvDrawParams().selectPoint() );

break;

case CV_EVENT_MOUSEMOVE:
if( data.selected != -1 )
{
data.vpt[data.selected] = data.pt_mouse;
data.vpt[data.selected].draw( data.img, CvDrawParams().selectPoint() );
}
actionM( param );
break;

Expand Down Expand Up @@ -193,7 +192,6 @@ void mouse_CB_6( int event, int x, int y, int /* flags */, void* param )
void action_1( void* param )
{
auto& data = *reinterpret_cast<Data*>(param);
// clearImage();
data.drawLines();

Line2d l( data.vpt[0], data.vpt[2] );
Expand Down Expand Up @@ -221,7 +219,6 @@ void demo_1( int nd )
Data data("lines");
std::cout << "Demo " << nd << ": click on points and move them\n";

// cv::setMouseCallback( data.wndname, mouse_CB_1, &data );
data.setMouseCallback( mouse_CB_1 );

int n=5;
Expand Down Expand Up @@ -702,31 +699,6 @@ void demo_H( int n )
//------------------------------------------------------------------
int main( int argc, const char** argv )
{
// std::cout << "float: " << std::numeric_limits<float>::digits10 << "\n";
// std::cout << "double: " << std::numeric_limits<double>::digits10 << "\n";
// std::cout << "long double:" << std::numeric_limits<long double>::digits10 << "\n";
#if 0
{
float f = M_PI;
double d = M_PI;
long double l = M_PI;
std::cout << "f=" << f << "\nd=" << d << "\nl=" << l << "\n";
for( int i=6; i<24; i=i+2)
{
std::cout << std::setprecision(i) << "- precision:" << i
<< ":\nf=" << f << "\nd=" << d << "\nl=" << l << "\n";
}

std::cout << "epsilon:\n-f=" << std::numeric_limits<float>::epsilon()
<< "\n-d=" << std::numeric_limits<double>::epsilon()
<< "\n-l=" << std::numeric_limits<long double>::epsilon()
<< "\n";


return 0;
}
#endif

std::cout << "homog2d graphical demo using Opencv"
<< "\n - homog version: " << HOMOG2D_VERSION
<< "\n - build with OpenCV version: " << CV_VERSION << '\n';
Expand Down
1 change: 0 additions & 1 deletion misc/homog2d.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<Unit filename="doxyfile" />
<Unit filename="extra_style_sheet.css" />
<Unit filename="homog2d_test.cpp" />
<Unit filename="precision_test_opencv.cpp" />
<Unit filename="test_all.sh" />
<Extensions>
<lib_finder disable_auto="1" />
Expand Down
8 changes: 7 additions & 1 deletion misc/homog2d_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,13 @@ TEST_CASE( "Segment", "[seg1]" )
auto pt = s1.getMiddlePoint();
CHECK( pt == Point2d_<NUMTYPE>(1,1) );
}

{ // test that points on a line at equal distance from a point, when
// transformed in a segment, we get back as middle point the same one.
Line2d li(9,9); // diagonal line (0,0) - (9,9)
auto ppts = li.getPoints( GivenCoord::X, 5, 1 );
Segment_<NUMTYPE> s1( ppts.first, ppts.second );
CHECK( s1.getMiddlePoint() == Point2d_<NUMTYPE>(5,5) );
}
}


Expand Down

0 comments on commit 72a1e93

Please sign in to comment.