I am getting this error when running openCV HoughCircle on large image
Exception has occurred: error OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 278963136 bytes in function 'cv::OutOfMemoryError' File "C:\Users", line 17, in main circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, rows / 8, param1=200, param2=100, minRadius=0, maxRadius=0) File "C:\Users", line 36, in main(sys.argv[1:]) Blockquote
import sys
import cv2
import numpy as np
def main(argv):
default_file = 'image.png'
filename = argv[0] if len(argv) > 0 else default_file
# Loads an image
src = cv2.imread(cv2.samples.findFile(filename), cv2.IMREAD_COLOR)
gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
gray = cv2.medianBlur(gray, 5)
rows = gray.shape[0]
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, rows / 8, param1=200, param2=100, minRadius=0, maxRadius=0)
# if circles is not None:
# circles = np.uint16(np.around(circles))
# for i in circles[0, :]:
# center = (i[0], i[1])
# # circle center
# cv2.circle(src, center, 1, (0, 100, 100), 3)
# # circle outline
# radius = i[2]
# cv2.circle(src, center, radius, (255, 0, 255), 3)
cv2.imshow("detected circles", src)
cv2.waitKey(0)
return 0
if __name__ == "__main__":
main(sys.argv[1:])