I am trying to read a image in opencv which is taken by gphoto2 but have success in doing so. below is the error i get. MY image is taken from a DSLR via usb to Jetson nano.
images/2021-01-31 Failed to create the new directory. Traceback (most recent call last): File "tigger_dslr.py", line 74, in <module> cv2.imshow("azx",q) TypeError: Expected Ptr<cv::UMat> for argument 'mat'
My Algorithm is :
import time #import sleep from datetime import datetime from sh import gphoto2 as gp import signal , os,subprocess import cv2 import numpy as np from PIL import Image from cStringIO import StringIO import Jetson.GPIO as GPIO channel = 7 GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(channel, GPIO.IN) #Kill the gphot porcess that starts when ever we connect the camera after a power cycle def killgphoto2Process(): p = subprocess.Popen(['ps','-A'],stdout = subprocess.PIPE) out , err = p.communicate() #search for the line that has the process #we want to kill for line in out.splitlines(): if b'gvfsd-ghoto2' in line : #kil the process pid = int(line.split(None,1)) os.kill(pid , signal .SIGKILL) shot_date = datetime.now().strftime("%Y-%m-%d") shot_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") picID = "" trigger_and_download= ["--stdout","--capture-image-and-download"] folder_name = shot_date + picID save_location = "images/" + folder_name print(save_location) def createSaveFolder(): try: os.makedirs(save_location) except: print("Failed to create the new directory.") os.chdir(save_location) def captureImages(): return gp(trigger_and_download) def renameFiles(ID): for filename in os.listdir("."): if len(filename) < 13 : os.rename(filename , (shot_time +ID + ".JPG")) killgphoto2Process() createSaveFolder() while True: z = GPIO.input(channel) if z == 0: qwe= captureImages() cv2.imshow("QWE",qwe)
their is a way around to first write the image on storage and then read it. but this is ugly engineering and is slow. i want to read it from the system ram
keeping in mind i already have gphoto2 istalled but canot make it python work