Python-Gphoto2のソースを表示
←
Python-Gphoto2
ナビゲーションに移動
検索に移動
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、以下のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
== 概要 == コマンド操作でカメラの制御を行います。 iso感度やシャッタスピード等の設定も可能です. == インストール == * debian apt install gphoto2 * Python (My Program) ==使用例 == <syntaxhighlight lang="python3"> class data: def __init__(self): self.buffer = [b"", b""] self.e = [False, False] self.f = False def set(self, d, val=0): self.buffer[val] = (b"--frame\r\n"+ b"Content-Type: image/jpeg\r\n\r\n" + d + b"\r\n") def get(self, val=0): return self.buffer[val] def start(self, val=0): self.e[val] = False def finish(self, val=0): self.e[val] = True def end(self, val=0): return self.e[val] def setFinal(self): self.f = True def final(self): return self.f datas = data() </syntaxhighlight> === カメラ設定最適化・初期化 === <syntaxhighlight lang="python3"> class GPhoto2: def __init__(self): self.iso = 3200 self.shutterspeed = 10 self.aperture = 2.8 self.capturetarget = 0 self.autofocusdrive = 0 self.manualfocusdrive = 3 self.eosremoterelease = 0 self.viewfinder = 2 self.autoexposuremode = 3 self.file = "" self.fileNames = [] self.log = "" self.json = [] self.setter = {"default":True,"capturetarget":False,"autofocusdrive":False, "manualfocusdrive":False,"eosremoterelease":False, "viewfinder":False,"autoexposuremode":False} self.finish = False self.turn = 0 self.log2 = ""; self.set(); def default(self): self.iso = "Auto" self.shutterspeed = "1/6" self.aperture = 2.8 self.capturetarget = 0 self.autofocusdrive = 0 self.manualfocusdrive = 3 self.eosremoterelease = 0 self.viewfinder = 2 self.autoexposuremode = 3 def setFileName(self,name): self.fileNames.append(name) def getFileName(self): return self.fileNames def setting(self): print("setting") if self.setter["default"]: self.log = "" self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'shutterspeed={self.shutterspeed}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'aperture={self.aperture}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'iso={self.iso}'],cwd=r"/home/azuma/public_html/public/" ,stdout=subprocess.PIPE,shell=False).stdout self.setter["default"] = False if self.setter["capturetarget"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'capturetarget={self.capturetarget}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["capturetarget"] = False if self.setter["autofocusdrive"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'autofocusdrive={self.autofocusdrive}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["autofocusdrive"] = False if self.setter["manualfocusdrive"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'manualfocusdrive={self.manualfocusdrive}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["manualfocusdrive"] = False if False: #if self.setter["eosremoterelease"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'eosremoterelease={self.eosremoterelease}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["eosremoterelease"] = False if self.setter["viewfinder"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'viewfinder={self.viewfinder}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["viewfinder"] = False if self.setter["autoexposuremode"]: self.log = subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--set-config' ,f'autoexposuremode={self.autoexposuremode}'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout self.setter["autoexposuremode"] = False #- 設定 # 各設定や制限などによる代入をコントロールするため個々に設定 def setIso(self,iso): self.iso = iso self.setter["default"] = True def setShutterspeed(self,shutterspeed): self.shutterspeed = shutterspeed self.setter["default"] = True def setAperture(self,aperture): self.aperture = aperture self.setter["default"] = True def setCapturetarget(self,capturetarget): self.capturetarget = capturetarget self.setter["capturetarget"] = True def setAutofocusdrive(self,autofocusdrive): self.autofocusdrive = autofocusdrive self.setter["autofocusdrive"] = True def setManualfocusdrive(self,manualfocusdrive): self.manualfocusdrive = manualfocusdrive self.setter["manualfocusdrive"] = True def setEosremoterelease(self,eosremoterelease): self.eosremoterelease = eosremoterelease self.setter["eosremoterelease"] = True def setViewfinder(self,viewfinder): self.viewfinder = viewfinder self.setter["viewfinder"] = True def setAutoexposuremode(self,autoexposuremode): self.autoexposuremode = autoexposuremode self.setter["autoexposuremode"] = True #gphoto2にあるパラメータを取得 def set(self): self.json = ["[shutterspeed]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'shutterspeed'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[iso]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'iso'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[aperture]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'aperture'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[capturetarget]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'capturetarget'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[autofocusdrive]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'autofocusdrive'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[manualfocusdrive]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'manualfocusdrive'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[eosremoterelease]\n Sorry... No Parameters", "\n\n[viewfinder]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'viewfinder'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout), "\n\n[autoexposuremode]\n"+str(subprocess.run(['/var/lib/snapd/snap/bin/gphoto2', '--get-config' ,'autoexposuremode'],cwd=r"/home/azuma/public_html/public/",stdout=subprocess.PIPE,shell=False).stdout) ] #- 取得 def get(self): return self.json def getIso(self): return self.iso def getShutterspeed(self): return self.shutterspeed def getAperture(self): return self.aperture def getCapturetarget(self): return self.capturetarget def getAutofocusdrive(self): return self.autofocusdrive def getManualfocusdrive(self): return self.manualfocusdrive def getEosremoterelease(self): return self.eosremoterelease def getViewfinder(self): return self.viewfinder def getAutoexposuremode(self): return self.autoexposuremode def AllGet(self): jsons = [ ["Iso",self.getIso()], ["Shutterspeed",self.getShutterspeed()], ["Aperture",self.getAperture()], ["Capturetarget",self.getCapturetarget()], ["Autofocusdrive",self.getAutofocusdrive()], ["Manualfocusdrive",self.getManualfocusdrive()], ["Eosremoterelease",self.getEosremoterelease()], ["Viewfinder",self.getViewfinder()], ["Autoexposuremode",self.getAutoexposuremode()] ] return jsons def logs(self): return self.log def setFinish(self): self.finish = True def getFinish(self): return self.finish def filename(self): if self.file: if self.turn: self.file = self.file+"_"+str(self.turn) path = f"/保存ディレクトリ/{self.file}.jpg" self.files.append(path) return f"--filename {path}" else: return "" def getfiles(self): return self.files def setTurn(self,turn): self.turn = turn def getTurn(self): return self.turn def cons(self,msg): print(str(msg)) self.log2 = str(msg); def getCons(self): return self.log2 gphoto = GPhoto2() </syntaxhighlight> === カメラ設定最適化・初期化 === <syntaxhighlight lang="python3"> </syntaxhighlight>
Python-Gphoto2
に戻る。
案内メニュー
個人用ツール
アカウント作成
ログイン
名前空間
ページ
議論
日本語
表示
閲覧
ソースを閲覧
履歴表示
その他
検索
案内
メインページ
最近の更新
おまかせ表示
MediaWikiについてのヘルプ
コード系
Program
PHP
Java
Python
Swift
JavaScript
HTML
CSS
C言語
MySQL
サーバー系
Apache2
OS系
Debian
kail
アプリケーション系
Xcode
Android Studio
計算系
ファイル系
速度系
メモ・業務
My命名規則
ツール
リンク元
関連ページの更新状況
特別ページ
ページ情報
編集
左メニュー
動画挿入について
動画・音声を追加する
JavaScriptを埋め込む
ページにリダイレクトを指定する