summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknolax <1339802534.kk@gmail.com>2017-01-17 17:39:50 +0000
committerknolax <1339802534.kk@gmail.com>2017-01-17 17:39:50 +0000
commit937e978c3cf5ba2b11f60c9622c828885798c268 (patch)
tree9ce574205481ec68508565c7b518863c33d2df20
parent4788300a8787c901f7d1bdec46d3c2553357736e (diff)
semifunctional capball and particle detection and differentiationstable
-rw-r--r--doc10
-rw-r--r--manyballs.jpgbin0 -> 706649 bytes
-rw-r--r--proc.py8
-rw-r--r--stallmask.jpgbin130024 -> 75670 bytes
-rw-r--r--stallmasked.jpgbin129759 -> 106008 bytes
-rw-r--r--stallmaskedcon.jpgbin230073 -> 194464 bytes
6 files changed, 15 insertions, 3 deletions
diff --git a/doc b/doc
index e61cd8c..69f33fc 100644
--- a/doc
+++ b/doc
@@ -45,3 +45,13 @@ blue or red
after testing with some other images, i have decided to move circle closeness requirement higher to 35, as i got one very clear picture of th capball that scored a 32%.
the diffrence in regularity is not good enough for distinguishing capball from particle.i
some more testing with the blue ball and one of them was a false negative. 3 more false positives, also one of the particles was below the cut off area. another false negative red ball at 36%, ut it was really covered up by a lot if stuff.
+1/17/2017
+ I am finding a new way to detect holes in the ball by masking the image with the cotour to
+ be differentiated, and then find the area of the countours there, in V values, as a percentage of
+ the area of the main contour.
+ I just found out that ret is te threshhold value found, OTSU automatically finds a threshold value between two peaks in the histogram. I want to use this for the first threshold but the re values for hue are not contigous, I will use i just for the red component of BGR. adaptive threshholding takes into consideration lighting conditions, this will be used in the second level maskin
+g.More info here:http://docs.opencv.org/trunk/d7/d4d/tutorial_py_thresholding.html
+ to make a mask from a contour, we simply make an empty image and draw the contours. we then threshhold the v value with adaptive thresholding, my fears about the 0s outside of the mask are unfounded.actually, it passess the entire black region as white. So i will do percentage of average instead.
+function used: conmasked = cv2.adaptiveThreshold(conmasked, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 3)
+I tried the mean of v in the contour, it only works on close ups, for now i guess we'll use size based ones.
+I'm decreasing the minimum size. after decreasing the size to 1000, the number of false negatives decreased. The particle differentiation based on contour percentage works reasonably well when the image is not blurry. I think for balls this will be the final build
diff --git a/manyballs.jpg b/manyballs.jpg
new file mode 100644
index 0000000..7bd31a9
--- /dev/null
+++ b/manyballs.jpg
Binary files differ
diff --git a/proc.py b/proc.py
index 7bdef13..607d424 100644
--- a/proc.py
+++ b/proc.py
@@ -17,8 +17,10 @@ h,s,v = cv2.split(himg)
#blue is 195-135, 40? really that much?
#hue only testing, not very effective.
# better with saturation
-thresh = cv2.bitwise_and(cv2.bitwise_or(thresh(h,0,10),thresh(h,169,180)), thresh(s,60,255))
-#thresh = cv2.bitwise_and(thresh(h,95,135), thresh(s,60,255))
+#red
+#thresh = cv2.bitwise_and(cv2.bitwise_or(thresh(h,0,10),thresh(h,169,180)), thresh(s,60,255))
+#blue
+thresh = cv2.bitwise_and(thresh(h,95,135), thresh(s,60,255))
#thresh = cv2.GaussianBlur(thresh,(29,29),0,0,cv2.BORDER_REFLECT_101)
cv2.imwrite("stallmask.jpg",thresh);
mask = cv2.merge((thresh,thresh,thresh))
@@ -28,7 +30,7 @@ cv2.imwrite("stallmasked.jpg",cv2.cvtColor(masked,cv2.COLOR_HSV2BGR));
im2, con, heir = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
v = 0
for i in range(0, len(con)) :
- if (cv2.contourArea(con[i]) > 2000) :
+ if (cv2.contourArea(con[i]) > 1000) :
a = cv2.contourArea(con[i])
cv2.drawContours(masked, con, i, (120,255,255), 5)
(cx, cy), r = cv2.minEnclosingCircle(con[i])
diff --git a/stallmask.jpg b/stallmask.jpg
index 78cde04..60894bd 100644
--- a/stallmask.jpg
+++ b/stallmask.jpg
Binary files differ
diff --git a/stallmasked.jpg b/stallmasked.jpg
index 055b940..01b13fa 100644
--- a/stallmasked.jpg
+++ b/stallmasked.jpg
Binary files differ
diff --git a/stallmaskedcon.jpg b/stallmaskedcon.jpg
index 687323d..4b389f9 100644
--- a/stallmaskedcon.jpg
+++ b/stallmaskedcon.jpg
Binary files differ