Forum

Author Topic: Add photos to the chunk  (Read 26374 times)

NougierEva

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add photos to the chunk
« Reply #30 on: November 24, 2017, 02:45:44 PM »
Thanks a lot for your response,
Now I want to align my photos.
I search on the net, and I find this sentences but it doesn't work and I already don't understand what's wrong with this two sentences.
The error is "An integer is required (got type str)".
This is my first question.
My second question is, how to detect automatically PhotoScan targets and how to import a list of GCP (.tx) and match them with the detection with of course the same name as detected. I let this in comment and I can't try wha't I write because my alignement of photos doesn't work.

Thanks a lot for your reactivity and your help,
Eva

magic

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Add photos to the chunk
« Reply #31 on: November 24, 2017, 06:19:56 PM »
re Hi Alexey

One more question 4 today
Now iv added a custom button with some action to my menu and my window works my button do my action , but i cant open my window once closed from my custom menu, when i restart ps my Custom menu is on place then i go to "Selection desactiver" and ---Nothing happens--- , when i add my script manually, will add second "selection desactiver" but its dsnt work ,  tell Alexey what is wrong with my code pls
Code: [Select]
import os
import PhotoScan
from tkinter import*


def center_window(width=300, height=200):
    # hoteur et largeur notre fenetre
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()

    # calcule positionement notre fenetre sur ecran
    x = (screen_width/2) - (width/2)
    y = (screen_height/2) - (height/2)
    root.geometry('%dx%d+%d+%d' % (width, height, x, y))




####
root = Tk()
center_window(500, 400)
root.title('selection images')


def callback():
    chunk = PhotoScan.app.document.chunk
    for camera in chunk.cameras:
        if camera.enabled:
            camera.selected = True
        else:
            camera.selected = False

but = Button(root, text='selection active', command=callback)

but.pack()


def selec():
    doc = PhotoScan.app.document
    chunk = doc.chunk
PhotoScan.app.addMenuItem("Custom/Selection desactiver", selec)
root.mainloop()


And have a nice weekend Alexey
Any ideas why thats dsnt work ??
« Last Edit: November 27, 2017, 03:51:09 PM by magic »

magic

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Add photos to the chunk
« Reply #32 on: November 28, 2017, 11:12:19 AM »
Hi Alexey

still can't figure out how to make it works, iv been tried few combinations and the script starting with my photoscan but once windows closed cant open it anymore, and it is normal did iv added 4 custom windows and they are opened with photoscan on start all ???
and im using 1.3.4 pro version photoscan

here is my code:
Code: [Select]
import PhotoScan
from tkinter import*

root = Tk()
center_window(500, 400)
root.title('selection images')

def center_window(width=300, height=200):
    # hoteur et largeur notre fenetre
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()

    # calcule positionement notre fenetre sur ecran
    x = (screen_width/2) - (width/2)
    y = (screen_height/2) - (height/2)
    root.geometry('%dx%d+%d+%d' % (width, height, x, y))

def myfunk():
    doc = PhotoScan.app.document
    chunk = doc.chunk

    def callback():
        chunk = PhotoScan.app.document.chunk
        for camera in chunk.cameras:
            if camera.enabled:
                camera.selected = True
            else:
                camera.selected = False

but = Button(root,bg='yellow',width =20, height =2, bd =2, relief =SOLID, text='selection active', command=callback)

but.pack()
root.mainloop()

PhotoScan.app.addMenuItem("Custom/Give me a name", myfunk)



Any help please Alexey ? I event tried put all my script in to the class and nothing, have not enough skills with python hope so one day that will changed ^-^ .

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #33 on: November 28, 2017, 03:08:30 PM »
Now I want to align my photos.
I search on the net, and I find this sentences but it doesn't work and I already don't understand what's wrong with this two sentences.
The error is "An integer is required (got type str)".
This is my first question.
My second question is, how to detect automatically PhotoScan targets and how to import a list of GCP (.tx) and match them with the detection with of course the same name as detected. I let this in comment and I can't try wha't I write because my alignement of photos doesn't work.
Hello Eva,

Probably, you have used outdated scripts as a reference, where string values instead of enum have been used.

See the modified parameters for the image matching:
Code: [Select]
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection = True, reference_preselection = False)
chunk.alignPhotos()
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #34 on: November 28, 2017, 03:11:55 PM »

still can't figure out how to make it works, iv been tried few combinations and the script starting with my photoscan but once windows closed cant open it anymore, and it is normal did iv added 4 custom windows and they are opened with photoscan on start all ???
and im using 1.3.4 pro version photoscan



Any help please Alexey ? I event tried put all my script in to the class and nothing, have not enough skills with python hope so one day that will changed ^-^ .
Hello magic,

What is written in the Console pane, when you are trying to run the script again?
Best regards,
Alexey Pasumansky,
Agisoft LLC

magic

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Add photos to the chunk
« Reply #35 on: November 28, 2017, 03:34:40 PM »
Hello Alexey

iv added 3 scripts
its looks like this:
Custom(and my 3 scripts)
                                          -test
                                          -test1
                                          -selection desactiver

when i choose 1st one send print to console but window stay off, no reaction at click
and 2 others nothing happens in console and window stay off to

but when i restart my photoscan all 3 windows are open, and i cant do any action before i close them
« Last Edit: November 28, 2017, 03:44:19 PM by magic »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #36 on: November 28, 2017, 04:24:22 PM »
Hello magic,

Maybe some issues with tkinter module installation?

You can use PySide2 module to create custom dialogs, even though it may be not so convenient, as trinker.
Best regards,
Alexey Pasumansky,
Agisoft LLC

magic

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Add photos to the chunk
« Reply #37 on: November 28, 2017, 04:37:31 PM »
I will try it Alexey thx

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #38 on: November 28, 2017, 05:01:22 PM »
Hello magic,

Check the scripts here that are using custom GUI elements as a reference:
https://github.com/agisoft-llc/photoscan-scripts
Best regards,
Alexey Pasumansky,
Agisoft LLC

NougierEva

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add photos to the chunk
« Reply #39 on: November 30, 2017, 12:29:00 PM »
Thanks for your answer, now it works.
But I have a question about the marker and GCP.
My automatic detection of the PhotoScan markers works but now, I would like to import a file with the coordinate of my GCP and ask the person to select the file because my file will not have necessary the same name each times.
How can I do that ?

Thansk a lot,
Have a nice day,
Eva Nougier

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #40 on: November 30, 2017, 12:43:10 PM »
Hello Eva,

Will the order of the columns and delimiter be fixed in the reference file? If so, can you provide as an example a few lines from it and specify, with columns correspond to which values that should be imported?
Best regards,
Alexey Pasumansky,
Agisoft LLC

NougierEva

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add photos to the chunk
« Reply #41 on: November 30, 2017, 12:59:43 PM »
My GCP file contains :
- point name same as PhotoScan (target 2, target 148, etc.)
- coordinate X of the point
- coordinate Y of the point
- coordinate Z of the point
To separate my data, I use a coma.
I already import this file when I did all the work without a Python Script and It works.
I put the file if you want to see.

In my mind, I would like to ask the person to specify the directory of the file (or files).
Then import the file or files.
And try to match the target automatically detected with PhotoScan and their coordinates.

Thanks,
Eva

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #42 on: November 30, 2017, 08:28:18 PM »
Hello Eva,

After detecting the markers you can add the following lines to your script:
Code: [Select]
path_csv = PhotoScan.app.getOpenFileName("Please specify the path to CSV file:", filter= "CSV file (*.txt *.csv)")
chunk.loadReference(path_csv, format = PhotoScan.ReferenceFormatCSV, columns = "nxyz", delimiter = ",")
It will ask the user for the path to the csv file and then would load the coordinate information to the Reference pane.

I can recommend to ask for the file paths in the beginning of the script, when the user just start them, because it may take a long time to wait for processing to get to the proper stage.
Best regards,
Alexey Pasumansky,
Agisoft LLC

NougierEva

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Add photos to the chunk
« Reply #43 on: December 01, 2017, 02:52:54 PM »
Hello,

Thanks for your answer, I fixe my problem thanks to your help. But I have another problem.
I need to precise the coordinate system of my GCP when I import the file as the same way I precise the concatenation of my file (a coma).
I put in attached file my script reviewed.

Really thanks for your help,
I will finish by understand Python Script, it's my goal !! =)
Eva

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15086
    • View Profile
Re: Add photos to the chunk
« Reply #44 on: December 01, 2017, 03:20:38 PM »
Hello Eva,

Not sure, what exactly do you need to perform after alignment?

If you need to optimize the camera positions, then the following function should be used:
Code: [Select]
optimizeCameras(fit_f=True, fit_cx=True, fit_cy=True, fit_b1=True, fit_b2=True, fit_k1=True, fit_k2=True, fit_k3=True, fit_k4=False, fit_p1=True, fit_p2=True, fit_p3=False, fit_p4=False)You may also need to use chunk.resetRegion() function to reset the position and orientation of the bounding box, that may be off from the camera alignment after referencing the model and optimization.
Best regards,
Alexey Pasumansky,
Agisoft LLC