def downloadImage(folder, image): gp(["--folder", folder, "--get-file", image])
def _captureImages(): # This function triggers the camera, downloads the picture that has been # taken and delete the picture on the camera gp(triggerAndDownload) gp(clearCommand)
scan_set = 1 exp_time_ms = 200 #Image time in miliseconds #Get monitor resolution sizes screens = screeninfo.get_monitors() main_res = screens[0].width, screens[0].height proj_res = screens[1].width, screens[1].height #Create window and move window to the second display cv2.namedWindow("My Window", cv2.WINDOW_NORMAL) cv2.moveWindow("My Window", main_res[0], 0) cv2.setWindowProperty("My Window", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) killgphoto2Process() gp(clearCommand) #Set up serial port for arduino arduino = serial.Serial('COM1', 115200, timeout=.1) #Number of angles per full revolution while True: while True: try: angles = int(input("Please enter number of angles per full rev: ")) except ValueError: print("Sorry, please enter integer.") continue else: break if (angles > 50) or (angles < 2):
from time import sleep from datetime import datetime from sh import gphoto2 as gp import signal, os, subprocess shot_date = datetime.now().strftime("%Y-%m-%d") shot_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") picID = "wv" deviceID = "cam1" # Set capturing target capturetarget = ["--set-config", "capturetarget=1"] gp(capturetarget) # clear the sd card clearCommand = [ "--folder", "/store_00020001/DCIM/100CANON", "-R", "--delete-all-files" ] triggerCommand = ["--trigger-capture"] downloadCommand = ["--get-all-files"] folder_name = shot_date + picID + "-" + deviceID save_location = "/home/pi/Desktop/wvtest/pics/" + folder_name def createSaveFolder(): try: os.makedirs(save_location)
captureImages() renameFiles(picID, shot_time + "raw_long") gp(small) gp(def_exp) captureImages() renameFiles(picID, shot_time + "small_short") gp(long_exp) captureImages() renameFiles(picID, shot_time + "small_long") exit() if __name__ == "__main__": picID = "Cannon200DShots" shot_time = datetime.now().strftime("%Y-%m-%d %H-%M-%S") folder_name = shot_time + picID save_location = "/home/syzygianinfern0/sambashare/Dataset/" + folder_name createSaveFolder(save_location) try: killGphoto2Process() except: print("No Camera to Kill\n") gp(clearCommand) gp(iso_init) main()
def init(): kill_gphoto2_process() gp(["--set-config", "capturetarget=1"])
listPic = os.listdir(".") listPic.sort() for filename in listPic: # if len(filename) < 13: if filename.endswith(".JPG"): name = str(pictures) name = name.zfill(3) pictures += 1 goodPrint("naming " + filename + " to img" + name + ".JPG") os.rename(filename, ("img" + name + ".JPG")) goodPrint("renamed the jpg") welcome() killgphoto2Process() gp(clearCommand) createSaveFolder() for i in range(num_max): captureImages() gp(downloadCommand) renameFiles() gp(clearCommand) bashCommand1 = "ffmpeg -start_number 001 -start_number_range " + str( num_max) + " -framerate 24 -i img%03d.JPG -codec:v mpeg4 output.mp4" os.chdir(parent_dir + "/" + directory) print(os.getcwd())
def captureImages(interval): while True: gp(["--trigger-capture"]) sleep(interval)
def captureImage(): gp(cameraTrigger) #sleep(3) gp(downloadCommand) gp(clearCommand) return True
os.system("ffmpeg -i "+ save_location+"/ex/frm_%04d.JPG -pix_fmt yuv420p "+main_dir_name+".mp4") # initial config arduino try: connection = SerialManager() a = ArduinoApi(connection = connection) except: print("failed to connect") print("connectted") a.pinMode(light_pin, a.OUTPUT) # Camera kill_gphoto2_process() create_save_dir(save_location) gp(clear_cmd) frame_counter = 0 counter = 0 print(" Frame name F_count Video length\n", "-"*60, "\n ", end="") try: capture_stack() export_frames() # align() enfuse render_video() except KeyboardInterrupt: rename_last_file() kill_gphoto2_process() a.digitalWrite(light_pin, a.LOW) print("\n", "-"*60, "\n", "Total frames: ", counter, "\nEstimated footage: ", counter/25)
def set_exposure(): gp(exposures[exco])
def printFilesInstaVintage(): if vintagemode == True: # trigger command print("printFilesVintage") killgphoto2Process() gp(clearCommand) gp(mediumCommand) #new feature - quality of campic createSaveFolder() ser.write(str.encode("s")) sleep(2.5) captureImage() # copy original image to vault vault_filename = renameFiles() # filename for stitched vintage image (will be printed) shot_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") instavintage_filename = os.path.join( image_vault2, ("InstaVintage_" + shot_time + ".JPG")) vintagename = get_vintagepic() # stitch pictures if watermark_mode: commands = [ # scale down the raw image "convert " + vault_filename + " -resize x640 -crop 640x640+160+0 insta_temporary.jpg", # put the vintage image and the scaled down raw image in a new file "convert " + insta_vintage_vorlage + " -gravity west " + vintagename + " -geometry +55-125 -composite" + " -gravity east insta_temporary.jpg -geometry +55-125 -composite " + " -gravity west " + watermark_background_vorlage_A + " -geometry +0-0 -composite " + instavintage_filename ] else: commands = [ # scale down the raw image "convert " + vault_filename + " -resize x640 -crop 640x640+160+0 insta_temporary.jpg", # put the vintage image and the scaled down raw image in a new file "convert " + insta_vintage_vorlage + " -gravity west " + vintagename + " -geometry +55-125 -composite" + " -gravity east insta_temporary.jpg -geometry +55-125 -composite " + " -gravity west " + watermark_background_vorlage_B + " -geometry +0-0 -composite " + instavintage_filename ] for command in commands: print("running command: ", command) ret = subprocess.run(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) print("stdout: ", ret.stdout.decode("utf-8")) print("stderr: ", ret.stderr.decode("utf-8")) if printon == True: printPic(instavintage_filename) elif vintagemode == False: # trigger command print("printFilesInsta2Pics") killgphoto2Process() gp(mediumCommand) #new feature - quality of campic process = None for img_id, arduino_command in enumerate(["m", "n"]): jpg_file = "{:d}.JPG".format(img_id + 1) # trigger command killgphoto2Process() gp(clearCommand) ser.write(str.encode("e")) #Nano mit Animation createSaveFolder() ser.write(str.encode(arduino_command)) sleep(4) captureImage() renameFiles(jpg_file) # wait for previous picture to be resized if process: process.wait() # resize current picture process = subprocess.Popen([ "convert", jpg_file, # resize the jpg file to be 640 pixels high (scale width accordingly) "-resize", "x640", # crop the image "-crop", "640x640+160+0", jpg_file ]) # stitch pictures if process: print("waiting 4 stitching...") process.wait() print("stitching...") shot_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") stitch_filename = os.path.join(image_vault2, ("Insta2Pics_" + shot_time + ".JPG")) if watermark_mode: commands = [ "convert " + insta_vorlage_A + " -gravity west 1.JPG -geometry +55-125 -composite " + " -gravity east 2.JPG -geometry +55-125 -composite " + " -gravity west " + watermark_background_vorlage_A + " -geometry +0-0 -composite " + stitch_filename ] else: commands = [ "convert " + insta_vorlage_B + " -gravity west 1.JPG -geometry +55-125 -composite " + " -gravity east 2.JPG -geometry +55-125 -composite " + " -gravity west " + watermark_background_vorlage_B + " -geometry +0-0 -composite " + stitch_filename ] print("stitching success!") for command in commands: print("running command: ", command) ret = subprocess.run(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) print("stdout: ", ret.stdout.decode("utf-8")) print("stderr: ", ret.stderr.decode("utf-8")) if printon == True: printPic(stitch_filename)
def imageList(folder): out = gp(["--folder", folder, "--list-files"]) return re.compile("[a-zA-Z0-9_]*.JPG").findall(str(out))
def triggerImages(delay=3): gp(triggerCommand) sleep(delay)
def main(): thermalcam = ThermalFeed() cv2.namedWindow("Shutter Button (_)") while True: thermalcam.thermal_update() k = cv2.waitKey(10) # k = pygame.event.get() # if k == 2: if k == 32: print("Taking Pics!") shot_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") gp(raw_and_large) gp(short_exp) captureImages() renameFiles(picID, shot_time + "raw_short") gp(long_exp) captureImages() renameFiles(picID, shot_time + "raw_long") gp(small) gp(short_exp) captureImages() renameFiles(picID, shot_time + "small_short") gp(long_exp) captureImages() renameFiles(picID, shot_time + "small_long") pygame.image.save(thermalcam.display, "thermal" + ".JPG") renameFiles(picID, shot_time + "thermal") break
def previewImage(): if os.path.exists('capture_preview.jpg'): os.remove('capture_preview.jpg') gp(previewcmd) image = Image.open('capture_preview.jpg') image.show()
def catprueImages(): gp(triggerCommand) sleep(1) gp(downloadCommand) gp(clearCommand)
def takePhotoWSQLDataTest(): killgphoto2Process() gp(clearCommand) createSaveFolder() scon = sqc.SQLConnector() currentid = scon.readFromDB(sqq.selectmaxidquery) print(currentid) query = sqq.selectLLSquery(currentid) LLS = scon.readFromDB(query) if LLS < 200: gp(autoisoCommand) gp(dayshutterspeedCommand) elif LLS > 200 and LLS < 400: gp(autoisoCommand) gp(dayshutterspeedCommand) else: gp(autoisoCommand) gp(dayshutterspeedCommand) captureImages() renameFiles(picID) sqlpathtophoto = (save_location + shot_time + picID + ".JPG") query = sqq.buildInsertCamQuery(sqlpathtophoto, currentid) scon.writeToDB(query)
def capture_image(album_location): img_path = album_location + datetime.now().strftime( "%Y.%m.%d %H:%M:%S") + ".JPG" gp(["--capture-image-and-download", "--filename", img_path, "--keep"]) return img_path
def takePhotoWSQLData(): killgphoto2Process() gp(saveinsdcardCommand) gp(clearCommand) createSaveFolder() scon = sqc.SQLConnector() currentid = scon.readFromDB(sqq.selectmaxidquery) query = sqq.selectLLSquery(currentid) LLS = scon.readFromDB(query) if LLS is not None: print("Current LLS: " + str(LLS)) if int(LLS) <= 200: gp(autoisoCommand) gp(dayshutterspeedCommand) elif int(LLS) > 200 and int(LLS) <= 640: gp(autoisoCommand) gp(sunsetshutterspeedCommand) elif int(LLS) > 640 and int(LLS) < 940: gp(autoisoCommand) gp(twilightshutterspeedCommand) else: gp(autoisoCommand) gp(nightshutterspeedCommand) captureImages() renameFiles(picID) sqlpathtophoto = (save_location + shot_time + picID + ".JPG") query = sqq.buildInsertCamQuery(sqlpathtophoto, currentid) scon.writeToDB(query) print("Camera end\n")
def captureImages(): gp(triggerCommand) goodPrint("took picture") sleep(3)
def captureImage(): gp(["--capture-image-and-download"])
def captureImages(): """ Generate image capture command """ gp(triggerCommand) sleep(12)
def captureImages(): print("Try") gp(triggerCommand) print("Downloaded")
def main(): thermal_camera = ThermalCamera() pygame.init() pygame.font.init() display = pygame.display.set_mode((320, 240)) pygame.display.set_caption("Thermal Cam") pygame.mouse.set_visible(True) while True: for event in pygame.event.get(): if event.type == KEYDOWN: print("Taking Pics!") shot_time = datetime.now().strftime("%Y-%m-%d %H-%M-%S") thermal_camera.trigger_camera() gp(raw_and_large) gp(def_exp) captureImages() renameFiles(picID, shot_time + "raw_short") gp(long_exp) captureImages() renameFiles(picID, shot_time + "raw_long") gp(small) gp(def_exp) captureImages() renameFiles(picID, shot_time + "small_short") gp(long_exp) captureImages() renameFiles(picID, shot_time + "small_long") exit()
def takePhoto(): gp(triggerCommand)
def captureImages(): gp(triggerCommand) sleep(3) gp(downloadCommand) gp(clearCommand)
def getPhoto(ID): capturePicture = [ "--capture-image-and-download", "--force-overwrite", "--filename", "images/" + str(ID).zfill(4) + ".jpg" ] gp(capturePicture)
def captureImages(): gp(triggerCommand) print("Bang!") sleep(33) # sleeps to allow for the image to be saved to memory
def setCaptureTarget(is_disk=1): gp(['--set-config', f'capturetarget={is_disk}'])