Skip to content

Commit

Permalink
Fix major bug with Agisoft install
Browse files Browse the repository at this point in the history
  • Loading branch information
s-du committed Jul 20, 2023
1 parent 499c0cb commit 2498663
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
15 changes: 0 additions & 15 deletions resources/other/camera_calib_m3t_no_process.xml

This file was deleted.

44 changes: 26 additions & 18 deletions tools/agisoft_part.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import os
import resources as res
from PySide6 import QtCore, QtGui, QtWidgets
import subprocess
import sys
import pkg_resources

if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
print('running in a PyInstaller bundle')

def install_agisoft_module():
# install Metashape module if necessary
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
else:
print('running in a normal Python process')
# if run in Python process, then the app needs to check if Agisoft is installed
import subprocess
import pkg_resources

metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl')
install(metashape_module)

# check if module is installed
required = {'metashape'}
installed = {pkg.key for pkg in pkg_resources.working_set}
print(installed)
missing = required - installed
if missing:
print(r"Ok let's intall Agisoft!")
install_agisoft_module()
def install_agisoft_module():
# install Metashape module if necessary
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl')
install(metashape_module)

# check if module is installed
required = {'metashape'}
installed = {pkg.key for pkg in pkg_resources.working_set}
print(installed)
missing = required - installed
if missing:
print(r"Ok let's intall Agisoft!")
install_agisoft_module()


import Metashape

Expand Down Expand Up @@ -75,9 +83,9 @@ def run(self):
pdf_path = os.path.join(self.output_folder, 'thermal_document.pdf')

# drone model specific data
if self.drone_model == 'MAVIC2-ENTERPRISE-ADVANCED':
if self.drone_model.name == 'MAVIC2-ENTERPRISE-ADVANCED':
calib_file = res.find('other/camera_calib_m2t.xml')
elif self.drone_model == 'M3T':
elif self.drone_model.name == 'M3T':
calib_file = res.find('other/camera_calib_m3t.xml')

# compute number of steps
Expand Down
1 change: 1 addition & 0 deletions tools/thermal_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

class DroneModel():
def __init__(self,name):
self.name = name
if name == 'MAVIC2-ENTERPRISE-ADVANCED':
self.rgb_xml_path = m2t_rgb_xml_path
self.ir_xml_path = m2t_ir_xml_path
Expand Down

0 comments on commit 2498663

Please sign in to comment.