I am using opencv in code that I wrote with python. I get a warning when working with visual studio code and it continues to work, but when I convert it to exe it closes without getting any error in the console.
The error I got with Visual Studio code:
[ WARN:0@8.123] global D:\a\opencv-python\opencv-python\opencv\modules\core\src\ocl.cpp (1020) cv::ocl::OpenCLExecutionContext::Impl::getInitializedExecutionContext OpenCL: Can't initialize OpenCL context/device/queue: unknown C++ exception
def __init__(mons, needle_img_path):
if needle_img_path:
mons.needle_img = cv2.imread(needle_img_path, cv2.IMREAD_UNCHANGED)
def find(mons):
locations = np.where()
locations = list(zip(*locations[::-1]))
if not locations:
return np.array([], dtype=np.int32).reshape(0, 4)
rectangles = []
for loc in locations:
rect = [int(loc[0]), int(loc[1]), mons.needle_w, mons.needle_h]
rectangles.append(rect)
rectangles = cv2.groupRectangles(rectangles, groupThreshold=1, eps=0.5)
return rectangles
def get_click_points(mons, rectangles):
points = []
for (x, y, w, h) in rectangles:
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
return points
def draw_rectangles(mons, haystack_img, rectangles):
line_color = (205, 0, 0)
line_type = cv2.LINE_8
for (x, y, w, h) in rectangles:
top_left = (x, y)
bottom_right = (x + w, y + h)
cv2.rectangle(haystack_img, top_left, bottom_right, line_color, lineType=line_type)
return haystack_img```