@@ -539,6 +539,64 @@ Methods
539
539
blob over its bounding box area. A low density ratio means in general that
540
540
the lock on the object isn't very good.
541
541
542
+ class Line -- Line object
543
+ =========================
544
+
545
+ The line object is returned by ``image.find_lines `` or ``image.find_line_segments ``.
546
+
547
+ .. method :: line.line()
548
+
549
+ Returns a line tuple (x1, y1, x2, y2) for use with other ``image `` methods
550
+ like ``image.draw_line ``.
551
+
552
+ .. method :: line.x1()
553
+
554
+ Returns the line's p1 x component.
555
+
556
+ You may also get this value doing ``[0] `` on the object.
557
+
558
+ .. method :: line.y1()
559
+
560
+ Returns the line's p1 y component.
561
+
562
+ You may also get this value doing ``[1] `` on the object.
563
+
564
+ .. method :: line.x2()
565
+
566
+ Returns the line's p2 x component.
567
+
568
+ You may also get this value doing ``[2] `` on the object.
569
+
570
+ .. method :: line.y2()
571
+
572
+ Returns the line's p2 y component.
573
+
574
+ You may also get this value doing ``[3] `` on the object.
575
+
576
+ .. method :: line.length()
577
+
578
+ Returns the line's length - sqrt(((x2-x1)^2) + ((y2-y1)^2).
579
+
580
+ You may also get this value doing ``[4] `` on the object.
581
+
582
+ .. method :: line.magnitude()
583
+
584
+ Returns the magnitude of the line from the hough transform.
585
+
586
+ You may also get this value doing ``[5] `` on the object.
587
+
588
+ .. method :: line.theta()
589
+
590
+ Returns the angle of the line from the hough transform - (0 - 179) degrees.
591
+
592
+ You may also get this value doing ``[7] `` on the object.
593
+
594
+ .. method :: line.rho()
595
+
596
+ Returns the the rho value for the line from the hough transform.
597
+
598
+ You may also get this value doing ``[8] `` on the object.
599
+
542
600
class QRCode -- QRCode object
543
601
=============================
544
602
@@ -1587,26 +1645,36 @@ Methods
1587
1645
regions that fall between these thresholds will be considered. For RGB565
1588
1646
images each tuple needs to have six values (l_lo, l_hi, a_lo, a_hi, b_lo,
1589
1647
b_hi) - which are minimums and maximums for the LAB L, A, and B channels
1590
- respectively. To easy usage this function will automatically fix swapped
1591
- min and max values. Additionally, a tuple is larger than six values the
1648
+ respectively. For easy usage this function will automatically fix swapped
1649
+ min and max values. Additionally, if a tuple is larger than six values the
1592
1650
rest are ignored. Conversely, if the tuple is too short the rest of the
1593
1651
thresholds are assumed to be zero.
1594
1652
1595
1653
.. note ::
1596
1654
1597
1655
To get the thresholds for the object you want to track just select (click
1598
- and drag) on the object you want to track. The histogram will then update
1599
- to just be in that area. Then just write down where the color
1600
- distribution starts and falls off in each histogram channel. These will
1601
- be your low and high values for ``thresholds ``. It's best to manually
1602
- determine the thresholds versus using the upper and lower quartile
1603
- statistics because they are too tight.
1656
+ and drag) on the object you want to track in the IDE frame buffer. The
1657
+ histogram will then update to just be in that area. Then just write down
1658
+ where the color distribution starts and falls off in each histogram channel.
1659
+ These will be your low and high values for ``thresholds ``. It's best to
1660
+ manually determine the thresholds versus using the upper and lower
1661
+ quartile statistics because they are too tight.
1662
+
1663
+ The latest version of OpenMV IDE features a threshold editor to help make
1664
+ picking thresholds easer. It lets you control the threshold with sliders
1665
+ so you can see what the thresholds are segmenting.
1604
1666
1605
1667
``roi `` is the region-of-interest rectangle tuple (x, y, w, h). If not
1606
1668
specified, it is equal to the image rectangle. Only pixels within the
1607
1669
``roi `` are operated on.
1608
1670
1609
- ``x_stride `` is the number of pixels to skip when searching for
1671
+ ``x_stride `` is the number of x pixels to skip when searching for a blob.
1672
+ Once a blob is found the line fill algorithm will be pixel accurate.
1673
+ Increase ``x_stride `` to speed up finding blobs if blobs are know to be large.
1674
+
1675
+ ``y_stride `` is the number of y pixels to skip when searching for a blob.
1676
+ Once a blob is found the line fill algorithm will be pixel accurate.
1677
+ Increase ``y_stride `` to speed up finding blobs if blobs are know to be large.
1610
1678
1611
1679
``invert `` inverts the thresholding operation such that instead of matching
1612
1680
pixels inside of some known color bounds pixels are matched that are outside
@@ -1656,6 +1724,86 @@ Methods
1656
1724
All the arguments except ``thresholds `` are keyword arguments and must
1657
1725
be explicitly invoked with their name and an equal sign.
1658
1726
1727
+ .. method :: image.find_lines(roi=Auto, x_stride=2, y_stride=1, threshold=1000, theta_margin=25, rho_margin=25)
1728
+
1729
+ Finds all infinite lines in the image using the hough transform. Returns a list
1730
+ of ``line `` objects (see above).
1731
+
1732
+ ``roi `` is the region-of-interest rectangle tuple (x, y, w, h). If not
1733
+ specified, it is equal to the image rectangle. Only pixels within the
1734
+ ``roi `` are operated on.
1735
+
1736
+ ``x_stride `` is the number of x pixels to skip when doing the hough transform.
1737
+ Only increase this if lines you are searching for are large and bulky.
1738
+
1739
+ ``y_stride `` is the number of y pixels to skip when doing the hough transform.
1740
+ Only increase this if lines you are searching for are large and bulky.
1741
+
1742
+ ``threshold `` controls what lines are detected from the hough transform. Only
1743
+ lines with a magnitude greater than or equal to ``threshold `` are returned. The
1744
+ right value of ``threshold `` for your application is image dependent. Note that
1745
+ the magnitude of a line is the sum of all sobel filter magnitudes of pixels
1746
+ that make up that line.
1747
+
1748
+ ``theta_margin `` controls the merging of detected lines. Lines which are
1749
+ ``theta_margin `` degrees apart and ``rho_margin `` rho apart are merged.
1750
+
1751
+ ``rho_margin `` controls the merging of detected lines. Lines which are
1752
+ ``theta_margin `` degrees apart and ``rho_margin `` rho apart are merged.
1753
+
1754
+ This method working by running the sobel filter over the image and taking
1755
+ the magnitude and gradient responses from the sobel filter to feed a hough
1756
+ transform. It does not require any preprocessing on the image first. However,
1757
+ my cleaning up the image filter you may get more stable results.
1758
+
1759
+ .. note ::
1760
+
1761
+ All the arguments are keyword arguments and must be explicitly invoked
1762
+ with their name and an equal sign.
1763
+
1764
+ .. method :: image.find_line_segments(roi=Auto, x_stride=2, y_stride=1, threshold=1000, theta_margin=25, rho_margin=25, segment_threshold=100)
1765
+
1766
+ Finds line segments in the image using the hough transform. Returns a list
1767
+ of ``line `` objects (see above).
1768
+
1769
+ ``roi `` is the region-of-interest rectangle tuple (x, y, w, h). If not
1770
+ specified, it is equal to the image rectangle. Only pixels within the
1771
+ ``roi `` are operated on.
1772
+
1773
+ ``x_stride `` is the number of x pixels to skip when doing the hough transform.
1774
+ Only increase this if lines you are searching for are large and bulky.
1775
+
1776
+ ``y_stride `` is the number of y pixels to skip when doing the hough transform.
1777
+ Only increase this if lines you are searching for are large and bulky.
1778
+
1779
+ ``threshold `` controls what lines are detected from the hough transform. Only
1780
+ lines with a magnitude greater than or equal to ``threshold `` are returned. The
1781
+ right value of ``threshold `` for your application is image dependent. Note that
1782
+ the magnitude of a line is the sum of all sobel filter magnitudes of pixels
1783
+ that make up that line.
1784
+
1785
+ ``theta_margin `` controls the merging of detected lines. Lines which are
1786
+ ``theta_margin `` degrees apart and ``rho_margin `` rho apart are merged.
1787
+
1788
+ ``rho_margin `` controls the merging of detected lines. Lines which are
1789
+ ``theta_margin `` degrees apart and ``rho_margin `` rho apart are merged.
1790
+
1791
+ ``segment_threshold `` controls what pixels are added to line segments. This
1792
+ is a threshold check on the magnitude of each pixel under an infinite line
1793
+ before it is added to a line segment under an infinite line.
1794
+
1795
+ This method works by calling ``find_lines `` internally and then walking
1796
+ each line found and checking the magnitude (using the sobel filter). If
1797
+ the magnitude passes the threshold check and if the pixel's gradient direction
1798
+ points in the same direction as the line then the pixel is added to a line
1799
+ segment under that line. All line segments are then merged repeatedly to
1800
+ create nice clean line segments.
1801
+
1802
+ .. note ::
1803
+
1804
+ All the arguments are keyword arguments and must be explicitly invoked
1805
+ with their name and an equal sign.
1806
+
1659
1807
.. method :: image.find_qrcodes(roi=Auto)
1660
1808
1661
1809
Finds all qrcodes within the ``roi `` and returns a list of ``qrcode ``
0 commit comments