Gupta
How to convert following code to elixir code.
I have made this program to detect digit and its position in a grid.
I know how to make simple elixir programs but I dont know how to make such complex programs in elixir because I dont know the syntax and about the libraries used in elixir.
I also searched about evision but very less reference I got, but not sufficient…
Here is my Python code:-
img = cv2.imread('digit_1.jpeg')
imgGrey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
_, thrash = cv2.threshold(imgGrey, 240, 255, cv2.THRESH_BINARY)
contours, _ = cv2.findContours(thrash, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
squares=0
for contour in contours:
approx = cv2.approxPolyDP(contour, 0.01* cv2.arcLength(contour, True), True)
if len(approx)==4:
cv2.drawContours(img, [approx],0, (255, 0, 0),2)
x = approx.ravel()[0]
y = approx.ravel()[1] - 5
if len(approx) == 4:
x1 ,y1, w, h = cv2.boundingRect(approx)
aspectRatio = float(w)/h
if aspectRatio >= 0.95 and aspectRatio <= 1.05 and (y1+h)*(x1+w) <985000:
squares +=1
#cv2.imshow("img", img)
for contour in contours:
approx = cv2.approxPolyDP(contour, 0.01* cv2.arcLength(contour, True), True)
if len(approx)==4:
cv2.drawContours(img, [approx],0, (255, 0, 0),2)
x = approx.ravel()[0]
y = approx.ravel()[1] - 5
if len(approx) == 4:
x1 ,y1, w, h = cv2.boundingRect(approx)
Please help me to convert this code into elixir code.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
That’s not just converting Python to Elixir code, you also need an image processing library.
This thread has a few references: Image processing library
Though I’d probably prefer the one described here: Image - an image processing library based upon Vix
…and by the same author, it even mentions eVision: GitHub - elixir-image/image: Image processing for Elixir · GitHub
Gupta
i want to do it using evision i have installed it in elixir but dont know which functions are available in evision similar to opencv so that i can use it accordingly
Gupta
and what are there syntex, arguments and parameters.
LostKobrakai
The docs should provide that:
Gupta
thank u for this i think this will help me
ROBERT23
When i run this it shows threshold image only in output but not draw contours on image ??
cocoa
As shown in your code, the python code is drawing on a copy of the original image (3-channel BGR) while you were drawing contours on the thresholded image (1-channel image).
So you can either draw contours on the original BGR image or change the color from
{0, 255, 0}to maybe{128}, but it could be very hard to see the color{128}in a gray scale image.ROBERT23
After drawing contours in image now i want to crop the sudoku grid but i am confuse in how to send the coordinates of grid in
Nx.sliceto crop image because draw contours give reference only, i also change it in tensor but it gives whole image pixels.Also, i use CHAIN_APPROX_SIMPLE() in find contours to get 4 boundary points of grid but it is not working, and gives all contours. ??
cocoa
For question 1, Nx.slice can only slice a rectangular area for you. To get the puzzle, you can use
Evision.warpPerspective. There is an example of this function, evision/examples/warp_perspective.livemd at main · cocoa-xu/evision · GitHub.For question 2, there could be 2 possible reasons,
Evision.findContours/3toEvision.cv_RETR_EXTERNAL(){4, 1, 2}. And based on the sample image, I guess you were following a blog post and if so, I think you missed some intermediate steps.