Oct-28-2024, 04:45 AM
Recently, there was a question about counting the numbers from a picture of 2 dice. I thought that was interesting, so I fiddled with it.
I import cv2 as cv and numpy as np in the main programme.
I ended up with a few functions of my own for various tasks, so I packed them all in a module called dice_stuff.py, which I import:
But I found, I had to pass cv and np to the module function ds.outline_dice() because it complained NameError no cv or NameError no np.
I already have cv and np imported in the main part of the programme.
How should I make cv and np available to my module functions?
What is the recommended way to do this? What is "Best Practice"?
I import cv2 as cv and numpy as np in the main programme.
I ended up with a few functions of my own for various tasks, so I packed them all in a module called dice_stuff.py, which I import:
import dice_stuff as dsFor example, I have a function:
outline_dice(png_copy, d, np, cv, destination)which draws a pretty green polyline around each die, once I have the coordinates.
But I found, I had to pass cv and np to the module function ds.outline_dice() because it complained NameError no cv or NameError no np.
I already have cv and np imported in the main part of the programme.
How should I make cv and np available to my module functions?
What is the recommended way to do this? What is "Best Practice"?