-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Anirudh-C/dfa-shape-detection
Dfa shape detection
- Loading branch information
Showing
18 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Circle Detection | ||
|
||
import cv2 | ||
import sys | ||
import numpy as np | ||
|
||
def DetectCircles(image): | ||
minpercent = 0.13 | ||
maxpercent = 0.33 | ||
height,width = image.shape[:2] | ||
minValue = min(height,width) | ||
maxValue = max(height,width) | ||
min_radius = int(minpercent * minValue/2) | ||
max_radius = int(maxpercent * maxValue/2) | ||
houghcircles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=min_radius,maxRadius=max_radius) | ||
houghcircles = np.uint16(np.around(houghcircles)) | ||
return houghcircles | ||
|
||
def test(): | ||
img = cv2.imread(sys.argv[1],0) | ||
for i in DetectCircles(img)[0,:]: | ||
cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2) | ||
cv2.circle(img,(i[0],i[1]),2,(0,0,255),3) | ||
cv2.imshow('detected circles',img) | ||
cv2.waitKey(0) | ||
cv2.destroyAllWindows() | ||
|
||
if __name__ == "__main__": | ||
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Circle Detection Module: | ||
|
||
To run the circle detection module, | ||
|
||
```bash | ||
python DFA/shapes/circle_detection.py /path/to/image | ||
``` | ||
|
||
**_Note_** : opencv, numpy are dependencies | ||
## Some sample runs: | ||
|
||
1. Perfect test case: | ||
|
||
test/test1.png | ||
|
||
![screenshot 1][test1] | ||
|
||
Here the circles are detected almost perfectly. But the accept state is not detected as 2 circles, | ||
because the circles are so close to each other. | ||
|
||
2. Semi-perfect test case: | ||
|
||
test/test2.png | ||
|
||
![screenshot 2][test2] | ||
|
||
test/test3.png | ||
|
||
![screenshot 3][test3] | ||
|
||
test/test4.png | ||
|
||
![screenshot 4][test4] | ||
|
||
test/test5.png | ||
|
||
![screenshot 5][test5] | ||
|
||
Here the states are all detected normally (except the accept state). But beyond a certain increase in curvature of arrows | ||
there are extra circles detected. | ||
|
||
3. Bad test cases: | ||
|
||
test/badtest1 | ||
|
||
![screenshot 6][badtest1] | ||
|
||
test/badtest2 | ||
|
||
![screenshot 7][badtest2] | ||
|
||
Here even the states are not detected properly. | ||
|
||
I think this can be fixed when arrow detection is done. | ||
|
||
The circles which share a common arc with the arrows must be deleted. | ||
|
||
[test1]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/test1.png "Test 1" | ||
|
||
[test2]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/test2.png "Test 2" | ||
|
||
[test3]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/test3.png "Test 3" | ||
|
||
[test4]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/test4.png "Test 4" | ||
|
||
[test5]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/test5.png "Test 5" | ||
|
||
[badtest1]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/badtest1.png "Bad Test 1" | ||
|
||
[badtest2]: https://github.com/anirudh-c/furry-spork-latex/blob/dfa-shape-detection/testout/badtest2.png "Bad Test 2" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.