
    9i\3                     6   S SK rSSKJrJrJrJr  SSKJrJ	r	J
r
Jr  SSKJr  SSKJr  SSKJr  SS	KJr  \R(                  " S
5      r/ SQr\" SS5       H6  r\" \\" \5         * \\" \5         S-   5       H  rS\S\-   S\-   4'   M     M8      " S S\\5      rg)    N   )FeatureDetectorDescriptorExtractor_mask_border_keypoints_prepare_grayscale_input_2D   )corner_fastcorner_orientationscorner_peakscorner_harris)pyramid_gaussian)check_nD)NP_COPY_IF_NEEDED)	_orb_loop)   r   )   r   r   r      r   r      r         
   	            i   r   c                   R    \ rS rSrSr      SS jrS rS rS rS r	S r
S	 rS
rg)ORB   a  Oriented FAST and rotated BRIEF feature detector and binary descriptor
extractor.

Parameters
----------
n_keypoints : int, optional
    Number of keypoints to be returned. The function will return the best
    `n_keypoints` according to the Harris corner response if more than
    `n_keypoints` are detected. If not, then all the detected keypoints
    are returned.
fast_n : int, optional
    The `n` parameter in `skimage.feature.corner_fast`. Minimum number of
    consecutive pixels out of 16 pixels on the circle that should all be
    either brighter or darker w.r.t test-pixel. A point c on the circle is
    darker w.r.t test pixel p if ``Ic < Ip - threshold`` and brighter if
    ``Ic > Ip + threshold``. Also stands for the n in ``FAST-n`` corner
    detector.
fast_threshold : float, optional
    The ``threshold`` parameter in ``feature.corner_fast``. Threshold used
    to decide whether the pixels on the circle are brighter, darker or
    similar w.r.t. the test pixel. Decrease the threshold when more
    corners are desired and vice-versa.
harris_k : float, optional
    The `k` parameter in `skimage.feature.corner_harris`. Sensitivity
    factor to separate corners from edges, typically in range ``[0, 0.2]``.
    Small values of `k` result in detection of sharp corners.
downscale : float, optional
    Downscale factor for the image pyramid. Default value 1.2 is chosen so
    that there are more dense scales which enable robust scale invariance
    for a subsequent feature description.
n_scales : int, optional
    Maximum number of scales from the bottom of the image pyramid to
    extract the features from.

Attributes
----------
keypoints : (N, 2) array
    Keypoint coordinates as ``(row, col)``.
scales : (N,) array
    Corresponding scales.
orientations : (N,) array
    Corresponding orientations in radians.
responses : (N,) array
    Corresponding Harris corner responses.
descriptors : (Q, `descriptor_size`) array of dtype bool
    2D array of binary descriptors of size `descriptor_size` for Q
    keypoints after filtering out border keypoints with value at an
    index ``(i, j)`` either being ``True`` or ``False`` representing
    the outcome of the intensity comparison for i-th keypoint on j-th
    decision pixel-pair. It is ``Q == np.sum(mask)``.

References
----------
.. [1] Ethan Rublee, Vincent Rabaud, Kurt Konolige and Gary Bradski
      "ORB: An efficient alternative to SIFT and SURF"
      http://www.vision.cs.chubu.ac.jp/CV-R/pdf/Rublee_iccv2011.pdf

Examples
--------
>>> from skimage.feature import ORB, match_descriptors
>>> img1 = np.zeros((100, 100))
>>> img2 = np.zeros_like(img1)
>>> rng = np.random.default_rng(19481137)  # do not copy this value
>>> square = rng.random((20, 20))
>>> img1[40:60, 40:60] = square
>>> img2[53:73, 53:73] = square
>>> detector_extractor1 = ORB(n_keypoints=5)
>>> detector_extractor2 = ORB(n_keypoints=5)
>>> detector_extractor1.detect_and_extract(img1)
>>> detector_extractor2.detect_and_extract(img2)
>>> matches = match_descriptors(detector_extractor1.descriptors,
...                             detector_extractor2.descriptors)
>>> matches
array([[0, 0],
       [1, 1],
       [2, 2],
       [3, 4],
       [4, 3]])
>>> detector_extractor1.keypoints[matches[:, 0]]
array([[59. , 59. ],
       [40. , 40. ],
       [57. , 40. ],
       [46. , 58. ],
       [58.8, 58.8]])
>>> detector_extractor2.keypoints[matches[:, 1]]
array([[72., 72.],
       [53., 53.],
       [70., 53.],
       [59., 71.],
       [72., 72.]])

c                     Xl         X l        X0l        X@l        XPl        X`l        S U l        S U l        S U l        S U l	        S U l
        g )N)	downscalen_scalesn_keypointsfast_nfast_thresholdharris_k	keypointsscales	responsesorientationsdescriptors)selfr!   r"   r#   r$   r%   r&   s          S/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/feature/orb.py__init__ORB.__init__w   sI     # &,      c           	      n    [        U5      n[        [        XR                  S-
  U R                  S S95      $ )Nr   )channel_axis)r   listr   r"   r!   )r,   images     r-   _build_pyramidORB._build_pyramid   s5    +E2}}q($..t
 	
r0   c                    UR                   n[        XR                  U R                  5      n[	        USS9n[        U5      S:X  a>  [        R                  " SUS9[        R                  " SUS9[        R                  " SUS94$ [        UR                  USS9nXE   n[        X[        5      n[        US	U R                  S
9nXtS S 2S4   US S 2S4   4   nXFU4$ )Nr   )min_distancer   )r   r   dtype)r   r   distancek)methodr=   )r:   r	   r$   r%   r   lennpzerosr   shaper
   
OFAST_MASKr   r&   )	r,   octave_imager:   fast_responser'   maskr*   harris_responser)   s	            r-   _detect_octaveORB._detect_octave   s    ""#L++t?R?RS Q?	y>Qu-U+U+  &l&8&8)bQO	*<JO'SDMMR#adOYq!t_$DE		11r0   c           	         [        US5        U R                  U5      n/ n/ n/ n/ n[        [        U5      5       H  n[        R
                  " X'   5      n[        R                  " U5      R                  S:  a    OU R                  U5      u  pnUR                  XR                  U-  -  5        UR                  U
5        UR                  [        R                  " U	R                  S   U R                  U-  UR                  S95        UR                  U5        M     [        R                  " U5      n	[        R                  " U5      n
[        R                  " U5      n[        R                  " U5      nU	R                  S   U R                   :  a  Xl        Xl        Xl        Xl        gUR+                  5       SSS2   SU R                    nX   U l        X   U l        X   U l        X   U l        g)z}Detect oriented FAST keypoints along with the corresponding scale.

Parameters
----------
image : 2D array
    Input image.

r   r   r9   N)r   r5   ranger?   r@   ascontiguousarraysqueezendimrH   appendr!   fullrB   r:   vstackhstackr#   r'   r(   r*   r)   argsort)r,   r4   pyramidkeypoints_listorientations_listscales_listresponses_listoctaverD   r'   r*   r)   r(   best_indicess                 r-   detect
ORB.detect   s    	%%e,CL)F//@Lzz,',,q0151D1D\1R.IY!!)nnf.D"DE$$\2OOA&NNF*&,, !!),% *( IIn-	yy!23;'IIn-	??1 0 00&N K ,&N %,,.tt45Gt7G7GHL&4DN .DK , :D&4DNr0   c                     [        UR                  USS9n[        R                  " X$   [        R                  S[
        S9n[        R                  " X4   SSS9n[        XU5      nXT4$ )N   r;   C)r:   ordercopyF)ra   rb   )r   rB   r@   arrayintpr   r   )r,   rD   r'   r*   rF   r+   s         r-   _extract_octaveORB._extract_octave   s`    %l&8&8)bQHHO277#<M
	 xx 2#EJF  r0   c                    [        US5        U R                  U5      n/ n/ n[        R                  " U5      [        R                  " U R                  5      -  R                  [        R                  5      n[        [        U5      5       H  n	X:H  n
[        R                  " U
5      S:  d  M#  [        R                  " XY   5      nX*   nXR                  U	-  -  nXJ   nU R                  XU5      u  pUR                  U5        UR                  U5        M     [        R                  " U5      R                  [        5      U l        [        R"                  " U5      U l        g)a  Extract rBRIEF binary descriptors for given keypoints in image.

Note that the keypoints must be extracted using the same `downscale`
and `n_scales` parameters. Additionally, if you want to extract both
keypoints and descriptors you should use the faster
`detect_and_extract`.

Parameters
----------
image : 2D array
    Input image.
keypoints : (N, 2) array
    Keypoint coordinates as ``(row, col)``.
scales : (N,) array
    Corresponding scales.
orientations : (N,) array
    Corresponding orientations in radians.

r   r   N)r   r5   r@   logr!   astyperd   rL   r?   sumrM   re   rP   rR   viewboolr+   rS   mask_)r,   r4   r'   r(   r*   rU   descriptors_list	mask_listoctavesrZ   octave_maskrD   octave_keypointsoctave_orientationsr+   rF   s                   r-   extractORB.extract   s!   ( 	%%e,	 66&>BFF4>>$::BB277KCL)F!+Kvvk"Q&!33GOD#,#9  NNF$:: &2&?#$($8$8 4G%! !''4  &! *$ 99%56;;DAYYy)
r0   c           	         [        US5        U R                  U5      n/ n/ n/ n/ n/ n[        [        U5      5       GHq  n[        R
                  " X(   5      n	[        R                  " U	5      R                  S:  a    GO3U R                  U	5      u  pn[        U
5      S:X  aL  UR                  U
5        UR                  U5        UR                  [        R                  " S[        S95        M  U R                  XU5      u  pX   U R                  U-  -  nUR                  U5        UR                  X   5        UR                  X   5        UR                  U R                  U-  [        R                  " UR                  S   [        R                   S9-  5        UR                  U5        GMt     [        U5      S:X  a  [#        S5      e[        R$                  " U5      n
[        R&                  " U5      n[        R&                  " U5      n[        R&                  " U5      n[        R$                  " U5      R)                  [        5      nU
R                  S   U R*                  :  a   Xl        UU l        Xl        Xl        Xl        gUR7                  5       SSS2   SU R*                   nU
U   U l        UU   U l        UU   U l        UU   U l        UU   U l        g)zDetect oriented FAST keypoints and extract rBRIEF descriptors.

Note that this is faster than first calling `detect` and then
`extract`.

Parameters
----------
image : 2D array
    Input image.

r   r   )r      r9   znORB found no features. Try passing in an image containing greater intensity contrasts between adjacent pixels.NrK   )r   r5   rL   r?   r@   rM   rN   rO   rH   rP   rA   rl   re   r!   onesrB   rd   RuntimeErrorrR   rS   rk   r#   r'   r(   r*   r)   r+   rT   )r,   r4   rU   rV   rY   rX   rW   rn   rZ   rD   r'   r*   r)   r+   rF   scaled_keypointsr(   r[   s                     r-   detect_and_extractORB.detect_and_extract"  s    	%%e,CL)F//@Lzz,',,q0151D1D\1R.IY9~"%%i0%%i0 ''(FG $ 4 4!K  )1GG!!"23!!)/2$$\%78&''*003277CD ##K07 *: {q G 
 IIn-	IIn-	;'yy!23ii 0166t<??1 0 00&N DK ,&N* %,,.tt45Gt7G7GHL&|4DN .DK ,\ :D&|4DN*<8Dr0   )r+   r!   r$   r%   r&   r'   rm   r#   r"   r*   r)   r(   N)g333333?r   i  r   g{Gz?g{Gz?)__name__
__module____qualname____firstlineno____doc__r.   r5   rH   r\   re   rt   r{   __static_attributes__ r0   r-   r   r      sC    [~  ,
2.65p	!1*fL9r0   r   )numpyr@   feature.utilr   r   r   r   cornerr	   r
   r   r   	transformr   _shared.utilsr   _shared.compatr   orb_cyr   rA   rC   
OFAST_UMAXrL   iabsjr   r   r0   r-   <module>r      s      R Q ( $ .  XXh
I
	sBAJs1v&&
3q6(:Q(>?%&
2626>" @ 

U9/. U9r0   