if SHOW_ROI: t.region_of_interest(frame, RESIZE_RATIO) if SHOW_TRACKING_AREA: # Desenha os Limites da Área de Tracking cv2.line(frame, (0, r(UPPER_LIMIT_TRACK)), (WIDTH, r(UPPER_LIMIT_TRACK)), t.WHITE, 2) cv2.line(frame, (0, r(BOTTOM_LIMIT_TRACK)), (WIDTH, r(BOTTOM_LIMIT_TRACK)), t.WHITE, 2) # Equalizar Contraste clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8)) hist = clahe.apply(frameGray) # cv2.imshow('img', np.vstack((frameGray,hist))) frameGray = hist frame_lane1 = t.perpective(frameGray, 1, RESIZE_RATIO) frame_lane2 = t.perpective(frameGray, 2, RESIZE_RATIO) frame_lane3 = t.perpective(frameGray, 3, RESIZE_RATIO) frameGray = frame_lane1 if ret is True: t.update_info_xml(frameCount, vehicle, dict_lane1, dict_lane2, dict_lane3) if SHOW_REAL_SPEEDS: t.print_xml_values(frame, RESIZE_RATIO, dict_lane1, dict_lane2, dict_lane3) fgmask = bgsMOG.apply(frameGray, None, 0.01) erodedmask = cv2.erode(fgmask, KERNEL_ERODE, iterations=1) dilatedmask = cv2.dilate(erodedmask, KERNEL_DILATE, iterations=1)
if SHOW_ROI: t.region_of_interest(frame, RESIZE_RATIO) if SHOW_TRACKING_AREA: # Desenha os Limites da Área de Tracking cv2.line(frame, (0, r(UPPER_LIMIT_TRACK)), (WIDTH, r(UPPER_LIMIT_TRACK)), t.WHITE, 2) cv2.line(frame, (0, r(BOTTOM_LIMIT_TRACK)), (WIDTH, r(BOTTOM_LIMIT_TRACK)), t.WHITE, 2) # Equalizar Contraste clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8)) hist = clahe.apply(frameGray) # cv2.imshow('img', np.vstack((frameGray,hist))) frameGray = hist im1Reg = t.perpective(frameGray, RESIZE_RATIO) frameGray = im1Reg if ret is True: t.update_info_xml(frameCount, vehicle, dict_lane1, dict_lane2, dict_lane3) if SHOW_REAL_SPEEDS: t.print_xml_values(frame, RESIZE_RATIO, dict_lane1, dict_lane2, dict_lane3) fgmask = bgsMOG.apply(frameGray, None, 0.01) erodedmask = cv2.erode(fgmask, KERNEL_ERODE, iterations=1) dilatedmask = cv2.dilate(erodedmask, KERNEL_DILATE, iterations=1) _, contours, hierarchy = cv2.findContours(dilatedmask, cv2.RETR_EXTERNAL,