Closed Jagan3534 closed 1 year ago
Please use the ElixirForum for questions/help/feedback, where a wider community will be able to help you. Thank you!
sorry sir i think my question is not understand clear sir
already i divided using {con,hei} = contours
in shell
i gave input like this but in color it getting error i check in evision but the example code in github its not working sir
OpenCV.drawContours(img,key,-1,(0,255,0),-1)
but my doubt is like in drawContour its getting an error like
color
should be a tuple, like (0,255,0)
is a tuple in python, {0,255,0}
is the corresponding tuple in elixir
- the fifth argument
I guess you want to specify thickness, so:
Evision.drawContours(src, contours, index, {0, 0, 255}, thickness: 2)
The example works, I tested it again. And a minimal one.
import Bitwise
# Load image in color
src = Evision.imread("pca_test.jpg")
# Load image in grayscale
gray = Evision.imread("pca_test.jpg", flags: Evision.cv_IMREAD_GRAYSCALE())
# binarization
{_, bw} = Evision.threshold(gray, 50, 255, Evision.cv_THRESH_BINARY() ||| Evision.cv_THRESH_OTSU())
# Find all the contours in the thresholded image
{contours, _} = Evision.findContours(bw, Evision.cv_RETR_LIST(), Evision.cv_CHAIN_APPROX_NONE())
contours =
contours
# Calculate the area of each contour
|> Enum.map(&{Evision.contourArea(&1), &1})
# Ignore contours that are too small or too large
|> Enum.reject(fn {area, _c} -> area < 100 or area > 100_000 end)
contours = Enum.map(contours, &elem(&1, 1))
# Draw each contour
src =
for index <- 0..(Enum.count(contours) - 1), reduce: src do
src ->
Evision.drawContours(src, contours, index, {0, 0, 255}, thickness: 2)
end
thanks a lot sir
hello sir, we have done it in python, how to we use sorted(contours, key=cv2.contourArea, reverse=True)[:15]
in elixir, is there any built in function to seperate edges in evision
location = None
# Finds rectangular contour
for contour in contours:
approx = cv2.approxPolyDP(contour, 15, True)
if len(approx) == 4:
location = approx
break```
This issue tracker is for reporting bugs. Please use Elixir Forum for help requests. And why are you calling Cocoa "sir"?
Reply Removed
i get the values of
findContours
after getting is their any method to seperatecontours
using in built function like in pythonimutil.grabcontours
the code is here
could please help us sir @cocoa-xu @josevalim