def mks2hg(prj_path, root_dir): mks = Commander('si', '=') hg = Commander('hg', ' ') root_prj = mks_get_project(mks, prj_path) # if hg already created, working on resync mode cp_syned = [] if os.path.exists(root_dir + '.hg'): cp_syned = hg_get_commited_cps(hg, root_dir) else: hg.init(root_dir) # retrieve list of cp to sync. cps = root_prj.get_changepackages(lambda id: id not in set(cp_syned)) # sync change packages. for cp in cps: cp.update_fs(root_prj) logging.info("Applying change packages...") for cp in cps: logging.debug(cp) if cp.apply_change(root_prj, root_dir): hg_commit(hg, root_dir, cp) else: logging.debug("Ignore cp %s)" % cp.id)
def mks2hg(prj_path, root_dir): mks = Commander('si', '=') hg = Commander('hg', ' ') root_prj = mks_get_project(mks, prj_path) # if hg already created, working on resync mode cp_syned = [] if os.path.exists(root_dir + '.hg'): cp_syned = hg_get_commited_cps(hg, root_dir) else: hg.init(root_dir) # retrieve list of cp to sync. cps = root_prj.get_changepackages(lambda id : id not in set(cp_syned)) # sync change packages. for cp in cps: cp.update_fs(root_prj) logging.info("Applying change packages...") for cp in cps: logging.debug(cp) if cp.apply_change(root_prj, root_dir): hg_commit(hg, root_dir, cp) else: logging.debug("Ignore cp %s)" % cp.id)
def __init__(self, type): self.__machines__ = Machines() self.__map__ = Map() self.__ip__ = '' self.__msg_ = '' self.string = Strings() self.com = Commander() if type == "UDP": self.udpModel = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) self.Open_U()
def main(): model1 = ModelDef(tf.keras.models.load_model("models/minstM.h5"), model1swaps) model2 = ModelDef(tf.keras.models.load_model("models/model2.h5"), model2swaps) ansamble = Ansamble([model1, model2], classes) segmentator = Segmentation(max_norm=254) segmentatorcv = SegmentatorCV() commander = Commander(ansamble, segmentator) #print(commander.eval("2p2.bmp")) print(commander.eval("txt2.bmp")) #print(commander.eval("complex_expression.bmp")) #print(commander.eval("extreme2.bmp")) #segmentatorcv.writeDigetsToFolder("extreme2.bmp", "ims") commander.writeDigetsToFolder("txt2.bmp", "ims")
class Server: stop = False socket_list = [] def __init__(self, type): self.__machines__ = Machines() self.__map__ = Map() self.__ip__ = '' self.__msg_ = '' self.string = Strings() self.com = Commander() if type == "UDP": self.udpModel = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) self.Open_U() def Open_T(self): pass def Open_U(self): if self.udpModel is not None: self.udpModel.bind((__config__.__HOST__, __config__.__PORT__)) self.ListenU(self.udpModel) def ListenU(self, model): while self.stop == False: __RECV__ = model.recvfrom(__config__.__BUFFER__) self.__ip__ = __RECV__[1] self.__stack__ = __RECV__[0] self.__machines__.Register(self.__ip__, self.__stack__) self.com.handler(self.__stack__.decode()) def Send(self, target): pass def __cmd__(self): pass def debug(self, addr, msg): if addr != "" and msg != "": print("{} : {}".format(str(addr), str(msg)))
import time from Commander import Commander if __name__ == "__main__": defaultWaitTime = 10 parser = ArgumentParser() parser.add_argument("--sourceFile", dest="source", type=str, help="JSON file containing player data. This will be used in addition to any command line parameters specifying another player.") parser.add_argument("--player", dest="player", default=None, choices=[1, 2], type=int, help="Player number to place bets on. If none is given, sourceFile is assumed to be used.") parser.add_argument("--factor, -f", dest="factor", type=int, default=0, choices=range(1, 100), help="Percent of balance to bet each round, from 1 to 100.") parser.add_argument("--amount, -a", dest="amount", type=int, default=0, help="Flat amount to bet each round. Overrides percentage arguments.") parser.add_argument("--waitTime", dest="waitTime", type=int, default=defaultWaitTime, help="Time to wait between server requests. Be nice to the server!") args = parser.parse_args() commander = Commander() if args.player is not None: #spawn a single player if one is specified player = "player1" if args.player == 1 else "player2" factor = args.factor amount = args.amount waitTime = args.waitTime try: email = raw_input("Email Address: ") except NameError: email = input("Email Address: ") finally: password = getpass("Password: ") commander.addBot(player, factor, amount, email, password, waitTime) if args.source:
sock.connect(server_address) class TestCmd(Command): def send(self, message): sock.send(message.encode()) def do_echo(self, *args): '''echo - Just echos all arguments''' return ' '.join(args) def do_raise(self, *args): raise Exception('Some Error') commander = Commander('RezChat', cmd_cb=TestCmd()) def run(): while 1: data = sock.recv(4096) if not data: break data = data.decode() split_data = data.split("{") for x in range(1, len(split_data)): split_data[x] = "{" + split_data[x] output = json.loads(split_data[x]) output["message"] = output["message"].rstrip("\n")
def crtdetail(request, video): from PIL import Image import cv2 video_instance = Video.objects.get(pk=video) video_url = video_instance.url use_i_th_frame = 300 #30==1sec data = PieChart.objects.filter(video_id=video_url) if data.count() < 1: print("There are no data. start task") current_path = os.path.dirname(os.path.abspath(__file__)) code_path = os.path.abspath(os.path.join(current_path, 'code')) videoModule_path = os.path.abspath( os.path.join(code_path, 'VideoModule')) sys.path.append(videoModule_path) from Commander import Commander commander = Commander() dumped, max_emotion_list, i_list, face_list = commander.for_youtube_video_TimeLine( use_i_th_frame, video_url) will_inserted = PieChart(video_id=str(video), json_data=dumped) img_path_list = [] for j in range(len(i_list)): fileName = str(video) + "_" + str(i_list[j]) + ".png" save_dir = os.path.abspath(os.path.join(current_path, 'images')) save_dir = os.path.abspath(os.path.join(save_dir, fileName)) destRGB = cv2.cvtColor(face_list[j], cv2.COLOR_BGR2RGB) pic_file = Image.fromarray(destRGB, 'RGB') pic_file.save(save_dir) img_path_list.append('./images/' + fileName) timeLog_list = [] for j in range(len(i_list)): second = (i_list[j] // 30) % 60 minute = ((i_list[j] // 30) // 60) % 60 hour = ((i_list[j] // 30) // 60) // 60 time_str = "" if hour < 10: time_str += ('0' + str(hour)) else: time_str += str(hour) time_str += ":" if minute < 10: time_str += ('0' + str(minute)) else: time_str += str(minute) time_str += ":" if second < 10: time_str += ('0' + str(second)) else: time_str += str(second) timeLog_list.append( TimeLog(top_sentiment=max_emotion_list[j], url=video_url, time=time_str, img_path=img_path_list[j])) for j in range(len(i_list)): timeLog_list[j].save() will_inserted.save() else: #already exist print("data already exist") pass return render(request, "yougam/index.html")
def __init__(self, df, df_name, path_to_output, *args, **kwargs): self.df = df self.df_name = df_name self.path_to_output = path_to_output #self.data_engine = kwargs.get('data_engine', None) self.auditing_config = kwargs.get('auditing_config', None) self.report_config = kwargs.get('report_config', None) def checkPlatform(): userPlatform = None if platform == "linux" or platform == "linux2" or platform == "darwin": userPlatform = "Linux" elif platform == "win32": userPlatform = "Window" print(userPlatform) return userPlatform def validateJSON(jsonData): try: json.loads(jsonData) except ValueError as err: return False return True def audited_dataset_to_csv(audited_dataset_with_tag): df = audited_dataset_with_tag del df['audit_result'] df.rename(columns={ 'audit_OOR': 'is_out_of_range', 'audit_pattern': 'is_incorrect_pattern', 'audit_OL': 'is_outliner', 'audit_MISS': 'is_missing_data' }, inplace=True) df['is_out_of_range'] = [ 'N' if x == 'pass' else 'out_of_range' for x in df['is_out_of_range'] ] df['is_incorrect_pattern'] = [ 'N' if x == 'pass' else 'incorrect_pattern' for x in df['is_incorrect_pattern'] ] df['is_outliner'] = [ 'N' if x == 'pass' else 'outliner' for x in df['is_outliner'] ] df['is_missing_data'] = [ 'N' if x == 'pass' else 'missing_data' for x in df['is_missing_data'] ] #print(df.columns) path_to_output = "{}/{}/{}/csv/".format(self.path_to_output, self.dataset_name, self.profile['profile_id']) fileName = "{}_with_tag.csv".format(self.dataset_name) df.to_csv('{}{}'.format(path_to_output, fileName), index=False) if (self.auditing_config != None): if (validateJSON(json.dumps(self.auditing_config))): print("auditing_config is Valid") else: print("auditing_config is not Valid") sys.exit(9) #----------------------------------Start Sakda----------------------- self.userPlatform = checkPlatform() result = Commander(self).action() data_profile = result['data_profile'] data_auditing = result['data_auditing'] data_viz = result['data_viz'] self.dataset_name = self.df_name self.profile = data_profile.profile self.duplicated_record = data_profile.df_duplicated_data self.schema = data_profile.schema self.schema_json = data_profile.schema_json self.blank_column = data_profile.blank_column self.columns = data_profile.columns self.profile_json = data_profile.profile_json self.column_profile = data_profile.column_profile self.column_profile_json = data_profile.column_profile_json if self.userPlatform == "Window": path_to_output = "{}\{}".format(path_to_output, self.dataset_name) print('====> {}\{}\csv\\'.format( path_to_output, data_profile.profile['profile_id'])) print('====> {}\{}\img\\'.format( path_to_output, data_profile.profile['profile_id'])) print('====> {}\{}\\report\\'.format( self.path_to_output, data_profile.profile['profile_id'])) else: path_to_output = "{}/{}".format(self.path_to_output, self.dataset_name) print('====> {}/{}/csv/'.format( path_to_output, data_profile.profile['profile_id'])) print('====> {}/{}/img/'.format( path_to_output, data_profile.profile['profile_id'])) print('====> {}/{}/report/'.format( path_to_output, data_profile.profile['profile_id'])) #------------------------------------------------------------- if (self.auditing_config != None): self.audited_result = data_auditing.audit_result self.audited_result_json = data_auditing.audit_result_json self.audited_dataset_with_tag = data_auditing.audited_dataset_with_tag self.audited_dataset_with_tag_to_csv = audited_dataset_to_csv( data_auditing.audited_dataset_with_tag) self.audited_dataset = data_auditing.audited_dataset
def __init__(self): self.get_all_devices() self.Commander = Commander() self.connect_all_devices()
class DeviceHandler(object): def __init__(self): self.get_all_devices() self.Commander = Commander() self.connect_all_devices() def get_all_devices(self): alle_ips_32= open(config.IP_Adressen_32bit).read() alle_ips_64= open(config.IP_Adressen_64bit).read() bereits_erledigt = open(config.Erledigte_Devices).read() self.ip_32 = ast.literal_eval(alle_ips_32) self.ip_64 = ast.literal_eval(alle_ips_64) self.erledigt = ast.literal_eval(bereits_erledigt) print("Found "+str(len(self.ip_64) + len(self.ip_32))+" devices\n") def add_device_64(self): ip = input("Please enter your IP Adress 64bit: ") self.ip_64.append(ip) datei = open(config.IP_Adressen_64bit,'w') datei.write(str(self.ip_64)) print("done CTRL+C to abort") datei.close() self.add_device_64() def add_device_32(self): ip = input("Please enter your IP Adress 32bit: ") self.ip_32.append(ip) datei = open(config.IP_Adressen_32bit,'w') datei.write(str(self.ip_32)) print("done CTRL+C to abort") datei.close() self.add_device_32() def list_devices(self): for device in self.ip_32: print(device," 32bit") for device in self.ip_64: print(device," 64bit") def connect_all_devices(self): for ip in self.ip_32: cmd = "adb connect "+str(ip) Ergebnis = self.Commander.use_system_command(cmd) for ip in self.ip_64: cmd = "adb connect "+str(ip) Ergebnis = self.Commander.use_system_command(cmd) def disconnect_all_devices(self): Ergebnis = self.Commander.use_system_command("adb disconnect") return(Ergebnis) def install_packages(self,ip): cmd = "adb -s "+ip+" install-multiple -r "+self.find_apks() #print(cmd) Ergebnis = self.Commander.use_system_command(cmd) return(Ergebnis) def uninstall_package(self,ip,packages): cmd = "adb -s "+ip+" uninstall "+str(packages) Ergebnis =self.Commander.use_system_command(cmd) return(Ergebnis) def find_apks(self): Files = glob.glob('*.apk') Befehl = "" Ausgabe = "" for a in Files: Befehl = Befehl + a + " " return(Befehl)
def sending(request): #웹캠 전달 받은 것 처리 if request.method == 'POST': #경로설정 current_path = os.path.dirname( os.path.abspath( __file__ ) ) code_path = os.path.abspath(os.path.join(current_path, 'code')) videoModule_path = os.path.abspath(os.path.join(code_path, 'VideoModule')) sys.path.append(videoModule_path) # 폴더 하나 써서 추가하기: webcams current_url = request.POST.get('url') video = int(current_url.split('/')[-3])#seed1 last_row = WebCam.objects.order_by('id').last()#### last_row_id = 0 if last_row is None: last_row_id = 0 else: last_row_id = last_row.id file_path =str(video) +'_' + str(last_row_id+1) +'.mp4' save_path = os.path.abspath(os.path.join(current_path, os.pardir)) save_path = os.path.abspath(os.path.join(save_path, 'media')) save_path = os.path.abspath(os.path.join(save_path, file_path)) with open(save_path, 'wb') as f:##경로 지정 하고, 이름 유니크하게 바꿔야. f.write(request.FILES['video'].read()) #분석 및 저장 use_i_th_frame = 9 #30==1sec from Commander import Commander import cv2 from PIL import Image import numpy as np commander = Commander() dumped, capture = commander.for_web_cam(use_i_th_frame, save_path) capture_path =str(video) +'_' + str(last_row_id+1) +'.png' capture_save_path = os.path.abspath(os.path.join(current_path, os.pardir)) capture_save_path = os.path.abspath(os.path.join(capture_save_path, 'media')) capture_save_path = os.path.abspath(os.path.join(capture_save_path, capture_path)) #print(capture_save_path) if len(dumped) != 0: destRGB = cv2.cvtColor(capture, cv2.COLOR_BGR2RGB) captured_img = Image.fromarray(destRGB, 'RGB') captured_img.save(capture_save_path) will_inserted = WebCam(video_id=str(video), json_data=dumped, video_path=save_path, capture_path=capture_path) will_inserted.save() else: return HttpResponse("Something Wrong in file uploading") context = {} return HttpResponse(json.dumps(context), "application/json")
def userdetail(request, video): video_url = Video.objects.get(pk=video) temp_url = video_url.url iframe_url = temp_url.replace('https://www.youtube.com/watch?v=','https://www.youtube.com/embed/') if Comment.objects.filter(video=video_url.id).count() < 1: comment_module_path=os.path.join(os.path.dirname( os.path.abspath( __file__ ) ), 'code/crawler') sys.path.append(comment_module_path) module_path=os.path.join(os.path.dirname(os.path.abspath( __file__ ) ), 'code/predict_sentiment') sys.path.append(module_path) comment_module_path2=os.path.join(os.path.dirname( os.path.abspath( __file__ ) ), 'code/predict_sentiment6') sys.path.append(comment_module_path2) with open("yougam/static/api_key/youtube_api.txt", "r") as y_api : YOUTUBE_API_KEY = y_api.readline() from youtube_api_cmd import YouTubeApi import sentiment_count import predict import spellcheck import random import sentiment_wordcloud comment_obj = YouTubeApi(100,video_url.url,YOUTUBE_API_KEY) comment_list = comment_obj.get_video_comment() video_title = comment_obj.get_video_title() video_url.title = video_title video_url.generate() print(video_title) print("--comment collect complete--") comments = spellcheck.spellchecker(comment_list) print("--comment spellcheck complete--") label = predict.labeling(comments) print("--comment positibe/negative complete--") #------crawling---------- predicted_comment_list = sentiment_count.predict_senti6(comment_list) predict_replies_list = {} reply_idx = 1 for comment_info in predicted_comment_list: comment_text = predicted_comment_list[comment_info]['comment'] comment_author = predicted_comment_list[comment_info]['author'] comment_period = predicted_comment_list[comment_info]['period'] comment_like = predicted_comment_list[comment_info]['like'] comment_label = predicted_comment_list[comment_info]['label'] comment_labelpn = label[comment_info]['label_pn'] parsed_date = dateutil.parser.parse(comment_period) parsed_date = parsed_date.strftime('%Y/%m/%d') ran = random.randint(1,9) parent_comment = video_url.comment_set.create(video = video, cid=comment_info,cmt = comment_text,label= comment_labelpn,label6 = comment_label, author = comment_author, period = parsed_date, like = comment_like,randnum=ran) # print(predicted_comment_list[comment_info]) if 'replies' in predicted_comment_list[comment_info].keys(): replies_list = predicted_comment_list[comment_info]['replies'] replies_list2 = label[comment_info]['replies'] # predicted_replies_list = sentiment_count.predict_senti6(replies_list) predicted_replies_list2 = spellcheck.spellchecker(replies_list2) predicted_replies_list2 = predict.labeling(predicted_replies_list2) parent_id = parent_comment.id for reply_info in replies_list: predict_replies_list[reply_idx] = replies_list[reply_info] reply_text = replies_list[reply_info]["comment"] reply_author = replies_list[reply_info]["author"] reply_period = replies_list[reply_info]["period"] reply_like = replies_list[reply_info]["like"] # reply_label = replies_list[reply_info]["label"] reply_labelpn = replies_list[reply_info]["label_pn"] parsed_date = dateutil.parser.parse(reply_period) parsed_date = parsed_date.strftime('%Y/%m/%d') this_reply = parent_comment.replydata_set.create(video = video,pid=comment_info, parent_id = parent_id, comment = reply_text, label = reply_labelpn, author = reply_author, period = parsed_date, like = reply_like) predict_replies_list[reply_idx]["rid"] = this_reply.id reply_idx += 1 predicted_replies_list = sentiment_count.predict_senti6(predict_replies_list) for i in predicted_replies_list: find_id = predicted_replies_list[i]["rid"] found_reply = ReplyData.objects.get(id=find_id) found_reply.label6 = predicted_replies_list[i]["label"] found_reply.generate() print("--comment6 predict complete--") predict_count_cmt = sentiment_count.sentenceCount(predicted_comment_list) predict_count_reply = sentiment_count.sentenceCount(predicted_replies_list) sentiment_wordcloud.wordcloud(predicted_comment_list, predicted_replies_list, video_url.id) cmt_count_list = [] reply_count_list = [] count_list = [] for senti in predict_count_cmt: cmt_count_list.append(predict_count_cmt[senti]) for senti in predict_count_reply: reply_count_list.append(predict_count_reply[senti]) for i in range(0,6): count_list.append(cmt_count_list[i] + reply_count_list[i]) print(count_list[i]) video_url.sentiment_neutral = count_list[0] video_url.sentiment_happy = count_list[1] video_url.sentiment_sad = count_list[2] video_url.sentiment_surprise = count_list[3] video_url.sentiment_anger = count_list[4] video_url.sentiment_fear = count_list[5] video_url.generate() cmt_neutral = Comment.objects.filter(video=video, label6='neutral').count() cmt_happy = Comment.objects.filter(video=video, label6='happy').count() cmt_sad = Comment.objects.filter(video=video, label6='sad').count() cmt_surprise = Comment.objects.filter(video=video, label6='surprise').count() cmt_anger = Comment.objects.filter(video=video, label6='anger').count() cmt_fear = Comment.objects.filter(video=video, label6='fear').count() rep_neutral = Comment.objects.filter(video=video, label6='neutral').count() rep_happy = Comment.objects.filter(video=video, label6='happy').count() rep_sad = Comment.objects.filter(video=video, label6='sad').count() rep_surprise = Comment.objects.filter(video=video, label6='surprise').count() rep_anger = Comment.objects.filter(video=video, label6='anger').count() rep_fear = Comment.objects.filter(video=video, label6='fear').count() loaded_count_list = [0,0,0,0,0,0] loaded_count_list[0] = cmt_neutral + rep_neutral loaded_count_list[1] = cmt_happy + rep_happy loaded_count_list[2] = cmt_sad + rep_sad loaded_count_list[3] = cmt_surprise + rep_surprise loaded_count_list[4] = cmt_anger + rep_anger loaded_count_list[5] = cmt_fear + rep_fear print(loaded_count_list) comments = Comment.objects.filter(video=video) reply = ReplyData.objects.filter(video=video) temp_url = video_url.url video_title = video_url.title iframe_url = temp_url.replace('https://www.youtube.com/watch?v=','https://www.youtube.com/embed/') vid = video_url.id print("comment predict complete!") print("video predict start!") from PIL import Image import cv2 video_instance = Video.objects.get(pk=video) video_url = video_instance.url use_i_th_frame = 300 #30==1sec data = PieChart.objects.filter(video_id=video)#video_url) #url로 하고 싶으면 이걸 사용. if data.count() < 1: print("There are no data. start task") current_path = os.path.dirname( os.path.abspath( __file__ ) ) code_path = os.path.abspath(os.path.join(current_path, 'code')) videoModule_path = os.path.abspath(os.path.join(code_path, 'VideoModule')) sys.path.append(videoModule_path) from Commander import Commander commander = Commander() dumped, max_emotion_list, i_list, face_list = commander.for_youtube_video_TimeLine(use_i_th_frame, video_url) will_inserted = PieChart(video_id = str(video), json_data = dumped) img_path_list = [] for j in range(len(i_list)): fileName = str(video) + "_" + str(i_list[j]) + ".png" save_dir = os.path.abspath(os.path.join(current_path, os.pardir)) save_dir = os.path.abspath(os.path.join(save_dir, 'media')) save_dir = os.path.abspath(os.path.join(save_dir, fileName)) destRGB = cv2.cvtColor(face_list[j], cv2.COLOR_BGR2RGB) pic_file = Image.fromarray(destRGB, 'RGB') pic_file.save(save_dir) img_path_list.append( fileName ) timeLog_list = [] for j in range(len(i_list)): second = (i_list[j]//30)%60 minute = ((i_list[j]//30)//60 )%60 hour = ((i_list[j]//30)//60 )//60 time_str = "" if hour<10: time_str += ('0' + str(hour)) else: time_str += str(hour) time_str += ":" if minute<10: time_str += ('0' + str(minute)) else: time_str += str(minute) time_str += ":" if second<10: time_str += ('0' + str(second)) else: time_str += str(second) timeLog_list.append( TimeLog(top_sentiment = max_emotion_list[j], url = video_url, time = time_str, img_path = img_path_list[j]) ) for j in range(len(i_list)): timeLog_list[j].save() will_inserted.save() else: print("data already exist") pass video_id = video video_instance = Video.objects.get(pk=video_id) video_url = video_instance.url logs = TimeLog.objects.filter(url=video_url) poll_results = PieChart.objects.get(video_id=video_id) return render(request, "yougam/user.html", {"count":loaded_count_list,"cmts":comments, "video_id":vid, "iframe_url":iframe_url,"logs": logs, "json" : SafeString(poll_results.json_data), "video_title":video_title,"reply":reply})
y1 = int(y0 + 1000 * a) x2 = int(x0 + 1000 * b) y2 = int(y0 - 1000 * a) cv2.line(frame, (x1, y1), (x2, y2), (0, 0, 255), 2) return rho, theta return None camera = Webcam() lower_bound = np.array([0, 128, 0]) upper_bound = np.array([255, 255, 128]) width_range = (int(0.4 * camera.width), int(0.6 * camera.width)) height1_range = (int(0 * camera.height), int(0.33 * camera.height)) height2_range = (int(0.33 * camera.height), int(0.67 * camera.height)) height3_range = (int(0.67 * camera.height), int(1 * camera.height)) commander = Commander(height1_range[1], width_range[1] - width_range[0]) while True: frame = camera.get_current_frame() upper_frame = frame[height1_range[0]:height1_range[1], width_range[0]:width_range[1]].copy() middle_frame = frame[height2_range[0]:height2_range[1], width_range[0]:width_range[1]].copy() lower_frame = frame[height3_range[0]:height3_range[1], width_range[0]:width_range[1]].copy() cv2.rectangle(frame, (width_range[0], height1_range[0]), (width_range[1], height1_range[1]), (0, 255, 0), 1) cv2.rectangle(frame, (width_range[0], height2_range[0]), (width_range[1], height2_range[1]), (0, 255, 0), 1) cv2.rectangle(frame, (width_range[0], height3_range[0]), (width_range[1], height3_range[1]), (0, 255, 0), 1) line_info = [process_frame(upper_frame), process_frame(middle_frame), process_frame(lower_frame)] line_info = [(index, info[0], info[1]) for index, info in enumerate(line_info) if info is not None] line_info = None if line_info == [] else line_info[0] cv2.imshow('mainframe', frame) cv2.imshow('upperframe', upper_frame)