return ynDATA, str_gpsE, str_gpsN def signal_handler(sig, frame): print('You pressed Ctrl+C!') now = datetime.datetime.now() time_data = "{}{}{}{}{}{}".format(now.year,str(now.month).zfill(2),str(now.day).zfill(2),\ str(now.hour).zfill(2),str(now.minute).zfill(2),str(now.second).zfill(2)) fo.write(str(frameID) + "|" + time_data + "|" + dataN + "," + dataE + "\n") sys.exit(0) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) bg_fresh = cv2.imread("bg.jpg") cam = webCam(id=0, videofile="", size=webcam_size) serial = serial.Serial(comPort, baudRate) out = '' dataE = dataN = "0" frameID = 0 lastE, lastN = "", "" statusAPP = 1 #1:recoeding, 0:recording paused if (cam.working() is True): if (video_out != ""): now = datetime.datetime.now() filename = "{}年{}月{}日{}點{}分{}秒".format(now.year, now.month, now.day, str(now.hour).zfill(2), str(now.minute).zfill(2), str(now.second).zfill(2))
now.hour, now.minute, now.second) print("d_{}_{}_{}.jpg".format(gps_data[0], gps_data[1], log_time)) print("o_{}_{}_{}.jpg".format(gps_data[0], gps_data[1], log_time)) filename_defect = "d_{}_{}_{}.jpg".format(gps_data[0], gps_data[1], log_time) filename_org = "o_{}_{}_{}.jpg".format(gps_data[0], gps_data[1], log_time) #print(filename_defect) cv2.imwrite(defect_out + "\\" + filename_defect, img_defect) cv2.imwrite(defect_out + "\\" + filename_org, img) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) if (video_type == 0): cam = webCam(id=cam_id, videofile="", size=webcam_size) else: cam = webCam(videofile=video_file_play, size=webcam_size) serial = serial.Serial(comPort, baudRate) out = '' dataE = dataN = "0" frameID = 0 lastE, lastN = "", "" if (cam.working() is True): if (video_out != ""): filename = video_out + str(time.time()) (width, height) = cam.camRealSize() if (write_video_out is True): fourcc = cv2.VideoWriter_fourcc(*'MJPG')
interval_gps_upload, img_waiting_path, img_uploaded_path, (upload_host, upload_port, recv_bit, upload_interval), )) #upload_img(interval_gps_upload, img_waiting_path, img_uploaded_path,(upload_host, upload_port, recv_bit, upload_interval)) #print("Upload img status:", proc_upload) #defect_file = new_log_filename() #logDefects = recordDefects(os.path.join(log_folder, defect_file), defect_count) #f = open(defect_info_write, "a") # for web gpsDevice = GPS(comport=comPort, portrate=baudRate, test=False) last_gps_logging = time.time() CAMERA = webCam(id=cam_id, videofile=simulate, size=webcam_size) defect_file = new_log_filename() logDefects = recordDefects(os.path.join(log_folder, defect_file), defect_count) last_long, last_lati = 00, 0.0 count_waiting, count_upload = 0, 0 (s_upload, s_gps, s_cam, msg) = check_env((upload_host, \ upload_port, recv_bit, upload_interval)) if (len(msg) > 0): choices = [ "1) re-scan", "2) continue", "3) exit ap", "4) reboot", "5) poweroff" ] ans = choicebox(msg, title='環境檢查', choices=choices)
gpsN = "N {}-{}-{}-{}".format(dataN1, dataN2, dataN3, dataN4) print(gpsE, gpsN) return ynDATA, gpsE, gpsN def signal_handler(sig, frame): print('You pressed Ctrl+C!') fo.write(str(frameID) + "|" + dataE + "/" + dataN + "\n") sys.exit(0) if __name__ == "__main__": signal.signal(signal.SIGINT, signal_handler) cam = webCam(id=0, size=webcam_size) serial = serial.Serial(comPort, baudRate) out = '' dataE = dataN = "0" frameID = 0 lastE, lastN = "", "" if (cam.working() is True): if (video_out != ""): filename = video_out + str(time.time()) (width, height) = cam.camRealSize() fourcc = cv2.VideoWriter_fourcc(*'MJPG') out = cv2.VideoWriter(video_out + str(time.time()) + ".avi", fourcc, frameRate, (int(width), int(height))) fo = open(filename + ".gps", "w") print("Video size is ", (width, height))