Class: CVFFI::ImagePatch::Result
- Inherits:
-
Object
- Object
- CVFFI::ImagePatch::Result
- Defined in:
- lib/opencv-ffi-wrappers/features2d/image_patch.rb
Instance Attribute Summary collapse
-
#angle ⇒ Object
Returns the value of attribute angle.
-
#center ⇒ Object
Returns the value of attribute center.
Class Method Summary collapse
Instance Method Summary collapse
- #==(b) ⇒ Object
- #distance_to(b) ⇒ Object
-
#initialize(center, patch, angle = 0.0, isOriented = false) ⇒ Result
constructor
A new instance of Result.
-
#orient_patch ⇒ Object
TODO: Consider whether rotating just the patch is ever a good idea or if you should always get the patch by rotating the original image.
- #oriented_patch ⇒ Object
- #patch(oriented = true) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(center, patch, angle = 0.0, isOriented = false) ⇒ Result
Returns a new instance of Result.
79 80 81 82 83 84 85 86 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 79 def initialize( center, patch, angle = 0.0, isOriented = false ) @center = CVFFI::Point.new center @patch = CVFFI::Mat.rows( patch, :CV_8U ) @angle = angle # Set this if the patch has already been rotated @oriented_patch = @patch if isOriented end |
Instance Attribute Details
#angle ⇒ Object
Returns the value of attribute angle.
77 78 79 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 77 def angle @angle end |
#center ⇒ Object
Returns the value of attribute center.
76 77 78 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 76 def center @center end |
Class Method Details
Instance Method Details
#==(b) ⇒ Object
88 89 90 91 92 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 88 def ==(b) @center == b.center and @angle == b.angle and @patch == b.patch end |
#distance_to(b) ⇒ Object
119 120 121 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 119 def distance_to( b ) patch.l2distance( b.patch ) end |
#orient_patch ⇒ Object
TODO: Consider whether rotating just the patch is ever a good idea or if you should always get the patch by rotating the original image
96 97 98 99 100 101 102 103 104 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 96 def orient_patch rotmat = CVFFI::CvMat.new CVFFI::cvCreateMat( 2,3, :CV_32F ) CVFFI::cv2DRotationMatrix( CVFFI::CvPoint2D32f.new( [ @patch.width/2.0, @patch.height/2.0 ]), -@angle*180.0/Math::PI, 1.0, rotmat ) dstimg = @patch.twin CVFFI::cvWarpAffine( @patch, dstimg, rotmat ) dstimg end |
#oriented_patch ⇒ Object
106 107 108 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 106 def oriented_patch @oriented_patch ||= orient_patch end |
#patch(oriented = true) ⇒ Object
110 111 112 113 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 110 def patch( oriented = true ) return @patch if angle == 0.0 or oriented == false oriented_patch end |
#to_a ⇒ Object
115 116 117 |
# File 'lib/opencv-ffi-wrappers/features2d/image_patch.rb', line 115 def to_a [ center.x, center.y, angle, oriented_patch.to_a ] end |