Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - UsmanJam

Pages: [1]
1
Hi All, i have been trying to create a very basic script using python to create a project and add photos from a folder and align them. However i am getting this error "NameError: name 'Metashape' is not defined". i have set the PYTHONPATH (screenshot attached) in the system varialbles, but the error presists. I have tried running the script standalone and through the python module in the Metashape installation directory, but result is the same. Can any one here help me with this please. Code is given below

import sys
import os

# Add the path to the Metashape Python module
# Replace this path with the actual path where Metashape is installed
metashape_path = "C:/Program Files/Agisoft/Metashape Pro/python"  # Modify this path as needed
sys.path.append(metashape_path)

import Metashape
import tkinter as tk
from tkinter import filedialog

# Function to select Metashape project file
def select_project_file():
    project_path = filedialog.askopenfilename(filetypes=[("Metashape Projects", "*.psx")])
    if project_path:
        project_label.config(text=project_path)
        global project_file_path
        project_file_path = project_path

# Function to select folder containing images
def select_folder():
    folder_path = filedialog.askdirectory()
    if folder_path:
        folder_label.config(text=folder_path)
        add_images_button.config(state="normal")
        global images_folder_path
        images_folder_path = folder_path

# Function to add images to Metashape project
def add_images_to_metashape():
    # Open Metashape project
    doc = Metashape.Document()
    doc.open(project_file_path)
   
    # Get the first chunk or create a new one if none exists
    if not doc.chunks:
        chunk = doc.addChunk()
    else:
        chunk = doc.chunks[0]
   
    # Add images to the chunk
    image_list = sorted(os.listdir(images_folder_path))[:100]
    image_paths = [os.path.join(images_folder_path, image) for image in image_list if image.lower().endswith(('jpg', 'jpeg', 'png', 'tif', 'tiff'))]
   
    chunk.addPhotos(image_paths)
   
    # Save the project
    doc.save()
    status_label.config(text="Images added successfully!")

# Create GUI
root = tk.Tk()
root.title("Add Images to Metashape Project")

frame = tk.Frame(root, padx=20, pady=20)
frame.pack(padx=10, pady=10)

project_label = tk.Label(frame, text="Select a Metashape project file")
project_label.pack(pady=5)

project_button = tk.Button(frame, text="Select Project File", command=select_project_file)
project_button.pack(pady=5)

folder_label = tk.Label(frame, text="Select a folder containing images")
folder_label.pack(pady=5)

folder_button = tk.Button(frame, text="Select Folder", command=select_folder)
folder_button.pack(pady=5)

add_images_button = tk.Button(frame, text="Add Images to Project", command=add_images_to_metashape, state="disabled")
add_images_button.pack(pady=20)

status_label = tk.Label(frame, text="")
status_label.pack(pady=5)

root.mainloop()
 

2
General / AMD Ryzen Threadripper PRO 7995WX
« on: April 23, 2024, 09:07:51 PM »
Is the AMD Ryzen Threadripper PRO 7995WX (96 Cores | 192 Threads | 5.1GHz Boost) a good choice for the CPU to process large datasets??

3
General / Hardware for Large Scale Projects
« on: April 23, 2024, 03:18:05 PM »
Hi All,

We are presently engaged in the implementation of an extensive project encompassing 180,000 images captured at a resolution of 45 megapixels each. The project involves the generation of Orthomosaics, Digital Surface Models (DSMs), Point Clouds, and Mesh Models.

Would appreciate it if you can recommend the right hardware configuration. Intel Xeon? i9? RTX 4090? single workstation or multiple? 2x Xeons? 2x RTXs? whatever it might be. Cost of the hardware is not the issue here.

Best Regards,

Pages: [1]