Skip to content

Commit

Permalink
Add EDColor code to EdgeDrawing Class
Browse files Browse the repository at this point in the history
fix for params.PFmode=true
Update edge_drawing.py
  • Loading branch information
sturkmen72 committed Jul 10, 2024
1 parent 438e67f commit 00aeb08
Show file tree
Hide file tree
Showing 5 changed files with 618 additions and 165 deletions.
4 changes: 2 additions & 2 deletions modules/ximgproc/include/opencv2/ximgproc/edge_drawing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class CV_EXPORTS_W EdgeDrawing : public Algorithm
void write(FileStorage& fs) const;
};

/** @brief Detects edges in a grayscale image and prepares them to detect lines and ellipses.
/** @brief Detects edges in a grayscale or color image and prepares them to detect lines and ellipses.
@param src 8-bit, single-channel, grayscale input image.
@param src 8-bit, single-channel or color input image.
*/
CV_WRAP virtual void detectEdges(InputArray src) = 0;

Expand Down
38 changes: 23 additions & 15 deletions modules/ximgproc/samples/edge_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,9 @@
import random as rng
import sys

rng.seed(12345)

def main():
try:
fn = sys.argv[1]
except IndexError:
fn = 'board.jpg'

src = cv.imread(cv.samples.findFile(fn))
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
cv.imshow("source", src)
def EdgeDrawingDemo(src, convert_to_gray):

rng.seed(12345)
ssrc = src.copy()*0
lsrc = src.copy()
esrc = src.copy()
Expand All @@ -43,9 +34,16 @@ def main():

ed.setParams(EDParams)

if convert_to_gray:
img_to_detect = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
else:
img_to_detect = src

cv.imshow("source image", img_to_detect)

# Detect edges
# you should call this before detectLines() and detectEllipses()
ed.detectEdges(gray)
ed.detectEdges(img_to_detect)

segments = ed.getSegments()
lines = ed.detectLines()
Expand Down Expand Up @@ -78,11 +76,21 @@ def main():
cv.ellipse(esrc, center, axes, angle,0, 360, color, 2, cv.LINE_AA)

cv.imshow("detected circles and ellipses", esrc)
cv.waitKey(0)
print('Done')
print('Press any key to swich color conversion code. Press Esc to exit.')


if __name__ == '__main__':
print(__doc__)
main()
try:
fn = sys.argv[1]
except IndexError:
fn = 'board.jpg'
src = cv.imread(cv.samples.findFile(fn))

convert_to_gray = True
key = 0
while key is not 27:
EdgeDrawingDemo(src, convert_to_gray)
key = cv.waitKey()
convert_to_gray = not convert_to_gray
cv.destroyAllWindows()
Loading

0 comments on commit 00aeb08

Please sign in to comment.