Seite 1 von 1
Error using OpenCV: histogram function
Verfasst: 28 Feb 2021, 16:55
von hvn
Hi,
I'm trying to use the OpenCV histogram function, but get this error:
hist1 = cv2.calcHist([hist_image1], [0], None, [256], [0, 256])
cv2.error: /home/richard/Projeckte/Fischertechnik/ftcommunity-TXT/buildroot/output/build/opencv3-3.3.0/modules/imgproc/src/histogram.cpp
error: (-210) in function calcHist
Does this mean I should use cv3 instead of cv2 or is this another issue?
Thanks,
hvn
Re: Error using OpenCV: histogram function
Verfasst: 01 Mär 2021, 18:38
von tintenfisch
Hi Huub,
hvn hat geschrieben: ↑28 Feb 2021, 16:55
I'm trying to use the OpenCV histogram function, but get this error:
hist1 = cv2.calcHist([hist_image1], [0], None, [256], [0, 256])
cv2.error: /home/richard/Projeckte/Fischertechnik/ftcommunity-TXT/buildroot/output/build/opencv3-3.3.0/modules/imgproc/src/histogram.cpp
error: (-210) in function calcHist
Does this mean I should use cv3 instead of cv2 or is this another issue?
"import cv2" is still correct with OpenCV 3.3.0, I think the problem has another cause.
cfw has some known issues with OpenCV but I don't know if these effect the above mentioned problem.
How do you get the "hist_image1"?
Best regards,
Lars
Re: Error using OpenCV: histogram function
Verfasst: 01 Mär 2021, 18:49
von hvn
Hi Lars,
hist_image1 = cv2.imwrite(filename_res, result)
Which does work...
Thanks,
hvn
Re: Error using OpenCV: histogram function
Verfasst: 01 Mär 2021, 18:55
von tintenfisch
hvn hat geschrieben: ↑01 Mär 2021, 18:49
hist_image1 = cv2.imwrite(filename_res, result)
Which does work...
Aha! cv2.imwrite() returns a boolean, not an image object.
You've to use cv2.imread() which returns an image, i.e.:
Code: Alles auswählen
success = cv2.imwrite(filename_res, result)
if success:
hist_image1 = cv2.imread(filename_res)
Or use the "result" variable as input for the calcHist function without saving the result first and re-read it.
Best regards,
Lars
Re: Error using OpenCV: histogram function
Verfasst: 01 Mär 2021, 20:28
von hvn
Ah ok, didn't think of that. Previously, I just used cv2.imwrite(...) and only for using histogram, I added hist_image1 to it.