ItsWajdy / modeler

A Python package to reconstruct 3D models from video
MIT License
48 stars 16 forks source link

Please make a demo. #1

Open 1chimaruGin opened 2 years ago

1chimaruGin commented 2 years ago

I follow README but it doesn't work.

SilenceOuO commented 2 years ago

I followed README but it doesn't work, too.

XyzzyX44 commented 1 year ago

I had to fix a bunch of stuff to get it to work.

First is the opencv version pip install opencv-contrib-python==3.4.2.17

next is the Matcher.py file, a couple tweaks. at or about line 92, change: fundamental, inliers = cv.findFundamentalMat(np.float32(points1), np.float32(points2), method=cv.FM_RANSAC, param1=self.distance, param2=self.confidence) to: fundamental, inliers = cv.findFundamentalMat(np.float32(points1), np.float32(points2), method=cv.FM_RANSAC,)

I put it together with my main.py Doesnt seem to save the .ply files in the right place, but will save in the main.py folder, but at least it will make the .ply files.

The styling of the comments here might mess up the tabbing, but you can figure that out easy. main.py:

from modeler import SfM import tkinter as tk from tkinter.filedialog import askopenfilename from tkinter.filedialog import askdirectory

class GUI: def gui(self):

Create window

    self.root = tk.Tk()
    self.root.title('3D Model from Video')

    # Set up Labels and buttons
    self.save_directory_label_text = tk.StringVar()
    self.save_directory_label_text.set("Choose a Directory to save results")
    self.save_directory_label = tk.Label(textvariable=self.save_directory_label_text)
    self.save_directory_label.grid(column=0, row=0)
    self.save_directory_button = tk.Button(text='Choose Directory', command=self.save_dir)
    self.save_directory_button.grid(column=1, row=0)

    self.video_directory_label_text = tk.StringVar()
    self.video_directory_label_text.set("Choose video file")
    self.video_directory_label = tk.Label(textvariable=self.video_directory_label_text)
    self.video_directory_label.grid(column=0, row=1)
    self.video_directory_button = tk.Button(text='Choose File', command=self.video_dir)
    self.video_directory_button.grid(column=1, row=1)

    self.convert_button = tk.Button(text='Convert Video to .ply model', command=self.convert)
    self.convert_button.grid(column=0, row=2, columnspan=2)

def save_dir(self):
    self.save_directory = askdirectory(title='Choose where to save your *.ply file')
    self.save_directory_label_text.set(self.save_directory)

def video_dir(self):
    self.video_directory = askopenfilename(title='Location of video to convert')
    self.video_directory_label_text.set(self.video_directory)

def convert(self):
    print(self.save_directory)
    self.sfm = SfM(self.save_directory, False, self.video_directory, 1)
    self.sfm.find_structure_from_motion()

window = GUI() window.gui()

window.root.mainloop()