import cv2 as cv import numpy as np #16-bit signed raw data input is required for this code to work #please change according to your camera resolution imgWidth=564 imgHeight=650 def processFrameforDisplay(frame): processed_frame=np.ndarray(shape=imgWidth*imgHeight, dtype='MAX]=MAX addedCopy[added8: framenum=0 centerx=(int)( imgWidth/2) centery=(int)(imgHeight/2) qwidth=(int)(imgWidth/4) qheight=(int)(imgHeight/4) added_mean=added[centerx-qwidth:centerx+qwidth, centery-qwidth:centery+qwidth].mean() added_std=added[centerx-qheight:centerx+qheight, centery-qheight:centery+qheight].std() print('mean: '+str(added_mean)) print(added_std) # added_std=100 MAX=added_mean+3*added_std MIN=added_mean-3*added_std gain=-(255)/(MAX-MIN) offset=-MAX*gain cv.imshow('final',display_frame) k = cv.waitKey(5) & 0xFF if k == 27: break cap.release() cv.destroyAllWindows()