Я пытаюсь изменить значения гаммы с помощью панели стека.Нужен ли мне массив, чтобы он работал, или есть какой-то другой способ сделать это, я нуб на python, и я не знаю другого языка программирования.
while (1):
# Capture frame-by-frame
cv2.createTrackbar("gammaLevel", "Disparity Map", 1, 10, nothing)
gammaLevel = 10
gammaLevel = cv2.getTrackbarPos("gammaLevel", "Disparity Map")
ret1, imgL = cap1.read()
ret2, imgR = cap2.read()
imgL = adjust_gamma(imgL, gammaLevel)
imgR = adjust_gamma(imgR, gammaLevel)
if (ret1 == True & ret2 == True):
window_size = 2
left_matcher = cv2.StereoSGBM_create(
minDisparity=0,
numDisparities=192, # max_disp has to be dividable by 16 f. E. HH 192, 256
blockSize=2,
P1=8 * 3 * window_size ** 2,
P2=32 * 3 * window_size ** 2,
disp12MaxDiff=1,
uniquenessRatio=15,
speckleWindowSize=50,
speckleRange=1,
preFilterCap=63,
mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)
right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)
# FILTER Parameters
lmbda = 800000
sigma = 1.0
visual_multiplier = 1.0
wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)
print('computing disparity...')
displ = left_matcher.compute(imgL, imgR) # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL) # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr) # important to put "imgL" here!!!
filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
ret, thresh1 = cv2.threshold(filteredImg, 210, 255, cv2.THRESH_BINARY)
# Display the resulting frame
cv2.imshow('Disparity Map', filteredImg)
#cv2.imshow('Frame1',thresh1)
#cv2.imshow('Frame2',imgR)
# Press Q on keyboard to exit
if cv2.waitKey(1) & 0xFF == ord('q'):
exit(0)