From 1430afd79f6d747d9992dfd05dc29e1083e2ae1e Mon Sep 17 00:00:00 2001 From: dronus <paul.geisler@web.de> Date: Tue, 10 Aug 2021 23:02:15 +0200 Subject: [PATCH] efficient histogram datatype, better histogram debug print --- linescan.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linescan.py b/linescan.py index 781d7b2..026dc72 100755 --- a/linescan.py +++ b/linescan.py @@ -140,7 +140,7 @@ sfps = SmoothedFpsCalculator() histogram_steps=conf["bins"] threshold=conf["threshold"] -last_histogram=np.zeros((histogram_steps)) +last_histogram=np.zeros(histogram_steps,dtype=np.uint16) # capture frames from the camera clahe=cv2.createCLAHE(clipLimit=conf["contrast_limit"]) @@ -161,7 +161,7 @@ for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True #line_frame_2=line_frame[0:1,1:num_keys+1] #retval,line_frame=cv2.threshold(line_frame_2,conf["threshold"],255,cv2.THRESH_BINARY) - histogram=np.zeros(histogram_steps) + histogram=np.zeros(histogram_steps,dtype=np.uint16) for pixel in np.nditer(line_frame): histogram[(int)(pixel*histogram_steps/256)]+=1 @@ -182,7 +182,7 @@ for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True pixel_count-=1 index+=1 - print("Pixels on: "+str(pixel_count)) + print("Pixels on: "+str(pixel_count)+":"+str(histogram)) last_histogram=np.copy(histogram) -- GitLab