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.


Messages - magic

Pages: [1] 2 3 4
1
Python and Java API / Access to Workspace with pyside2 GUI
« on: August 13, 2018, 02:02:19 PM »
Hi all,
I have my GUI made with PySide2 and I do some action in first QPlainTextEdit() window.
 I'm printing my selected groups, I would like to know did it is possible to move or copy my workspace tree to QPlainTextEdit() window or QTextEdit() or any others possibility , to get my work more safety , means selecting my groups in my GUI, not direct in my Workspace ?? Coz last week I made some error and I lost my work, I had to start from beginning(from my save), We can do it with python API ??

2
Python and Java API / Re: Calibration from xml files
« on: August 13, 2018, 01:33:55 PM »
I've modified that a little and it's working too, Thanks Alexey :-)
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"            ### PATH POUR HERO6 BLACK
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"       ### PATH POUR HERO4 SESSION
doc = PhotoScan.app.document

for chunk in doc.chunks:
    calib_session = PhotoScan.Calibration()
    sensor_session = chunk.addSensor()
    calib_session.load(session_xml)
    sensor_session.width = calib_session.width
    sensor_session.height = calib_session.height
    sensor_session.user_calib = calib_session
    calib_black = PhotoScan.Calibration()
    calib_black.load(black_xml)
    sensor_black = chunk.addSensor()
    sensor_black.width = calib_black.width
    sensor_black.height = calib_black.height
    sensor_black.user_calib = calib_black

    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        print(camera, dd)
        if dd == "HERO4 Session":
            camera.sensor = sensor_session

        if dd == "HERO6 Black":
            print(camera, " hero black")
            camera.sensor = sensor_black

        else:
            pass

3
Python and Java API / Re: Calibration from xml files
« on: August 08, 2018, 05:53:23 PM »
Or something like that Alexey ?? still have all cameras separated , not two models
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"

cameraId = 0
for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        print(camera, dd)
        if dd == "HERO4 Session":
            print(camera, " hero session")
            calib = PhotoScan.Calibration()
            calib.load(session_xml)
            doc = PhotoScan.app.document
            #sensor_session = chunk.sensors[0]
            sensor_session = chunk.addSensor()
            sensor_session.width = camera.sensor.width
            sensor_session.height = camera.sensor.height
            camera.sensor = sensor_session

            sensor_session.calibration = calib
            sensor_session.user_calib = calib
        if dd == "HERO6 Black":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(black_xml)
            doc = PhotoScan.app.document
            sensor_black = chunk.addSensor()
            #sensor_black = chunk.sensors[0]
            sensor_black.width = camera.sensor.width
            sensor_black.height = camera.sensor.height
            camera.sensor = sensor_black

            sensor_black.calibration = calib
            sensor_black.user_calib = calib

4
Python and Java API / Re: Calibration from xml files
« on: August 08, 2018, 05:42:28 PM »
I don't know did I understood, should be then something like that ??
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"

cameraId = 0
for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        print(camera, dd)
        sensor = chunk.addSensor()
        sensor.width = camera.sensor.width
        sensor.height = camera.sensor.height
        calib = PhotoScan.Calibration()
        sensor_session = calib.load(session_xml)
        sensor_black =calib.load(black_xml)
        #doc = PhotoScan.app.document
        # sensor = chunk.sensors[0]

        sensor.calibration = calib
        sensor.user_calib = calib
        if dd == "HERO4 Session":
            print(camera, " hero session")
            camera.sensor = sensor_session

        if dd == "HERO6 Black":
            print(camera, " hero black")
            camera.sensor = sensor_black
But when I run it ,have an error:
Code: [Select]
     24         if dd == "HERO4 Session":
     25             print(camera, " hero session")
---> 26             camera.sensor = sensor_session
     27
     28         if dd == "HERO6 Black":

TypeError: expected  PhotoScan.Sensor object

5
Python and Java API / Re: Calibration from xml files
« on: August 08, 2018, 05:14:18 PM »
Hi Alexey,
I have to set the sensor to?? I can't pass the params from xml without sensor , and width and height the are already in my
xml , but modified it like this and now, it works but for all images, don't see a difference, between models , he apply my script to all cameras
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"

cameraId = 0
for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        print(camera, dd)
        if dd == "HERO4 Session":
            print(camera, " hero session")
            calib = PhotoScan.Calibration()
            calib.load(session_xml)
            doc = PhotoScan.app.document.chunk
            sensor = chunk.sensors[0]
            sensor.width = camera.sensor.width
            sensor.height = camera.sensor.height
            camera.sensor = sensor
            #sensor = chunk.addSensor()

            sensor.calibration = calib
            sensor.user_calib = calib
        if dd == "HERO6 Black":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(black_xml)
            doc = PhotoScan.app.document.chunk
            #sensor = chunk.addSensor()
            sensor = chunk.sensors[0]
            sensor.width = camera.sensor.width
            sensor.height = camera.sensor.height
            camera.sensor = sensor


and that is a my print for models:
Code: [Select]
2018-08-08 16:09:52 <Camera 'BR01_2018-07-24_GOPR0459.JPG'>  hero session
2018-08-08 16:09:52 <Camera 'BR01_2018-07-24_GOPR0460.JPG'> HERO4 Session
2018-08-08 16:09:52 <Camera 'BR01_2018-07-24_GOPR0460.JPG'>  hero session
2018-08-08 16:09:52 <Camera 'BR01_2018-07-24_GOPR0461.JPG'> HERO4 Session
2018-08-08 16:09:52 <Camera 'BR01_2018-07-24_GOPR0461.JPG'>  hero session
2018-08-08 16:09:52 <Camera 'G0123782.JPG'> HERO6 Black
2018-08-08 16:09:52 <Camera 'G0123782.JPG'>  hero black
2018-08-08 16:09:52 <Camera 'G0123783.JPG'> HERO6 Black
Why my if-s doe's not work???
I think there is some problem with sensor declaration, when I comment  >>sensor = chunk.sensors[0]
and I use >>sensor = chunk.addSensor() like this:
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"

cameraId = 0
for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        print(camera, dd)
        if dd == "HERO4 Session":
            print(camera, " hero session")
            calib = PhotoScan.Calibration()
            calib.load(session_xml)
            doc = PhotoScan.app.document.chunk
            #sensor = chunk.sensors[0]
            sensor = chunk.addSensor()
            sensor.width = camera.sensor.width
            sensor.height = camera.sensor.height
            camera.sensor = sensor

            sensor.calibration = calib
            sensor.user_calib = calib
        if dd == "HERO6 Black":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(black_xml)
            doc = PhotoScan.app.document.chunk
            sensor = chunk.addSensor()
            #sensor = chunk.sensors[0]
            sensor.width = camera.sensor.width
            sensor.height = camera.sensor.height
            camera.sensor = sensor

            sensor.calibration = calib
            sensor.user_calib = calib
I have no more models groups but my parameters are applied correctly, What I have to change Alexey??

6
Python and Java API / Re: Calibration from xml files
« on: August 08, 2018, 04:43:58 PM »
Doe's one works only for first group:
Second stay empty:
Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"

cameraId = 0
for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        if dd == "HERO6 Black":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(black_xml)
            doc = PhotoScan.app.document
            sensor = chunk.addSensor()

            sensor.calibration = calib
            sensor.user_calib = calib
        else:
            #dd == "HERO4 Session"
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(session_xml)
            doc = PhotoScan.app.document
            sensor = chunk.sensors[0]

            sensor.calibration = calib
            sensor.user_calib = calib

7
Python and Java API / Calibration from xml files
« on: August 08, 2018, 04:19:21 PM »
Hi team,
I would like to ask You how can I use calibrated parameters from xml file,
I have 2 different camera exif model  , and I would like to apply different  params for different  models,
for all my cameras in few chunks from my 2 xml files (with parameters),
I've tried few combination and doe's not want to go
That my script:

Code: [Select]
import PhotoScan

black_xml = "F:\calibration_ps\CAL_HERO6_2.xml"
session_xml = "F:\calibration_ps\CAL_SESSION4_2.xml"


for chunk in PhotoScan.app.document.chunks:
    #chunk.estimateImageQuality(chunk.cameras)
    for camera in chunk.cameras:
        #print(camera)
        dd = camera.photo.meta["Exif/Model"]
        if dd == "HERO6 Black":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(black_xml)
            calib = True
        if dd == "HERO4 Session":
            print(camera, " hero black")
            calib = PhotoScan.Calibration()
            calib.load(session_xml)
            calib = True

I'm taking out a meta model , printing it and working well but I cant apply my xml file , what I have to change over here ???

8
Python and Java API / Re: BuildModel params network
« on: August 01, 2018, 05:27:12 PM »
I've past it for furthers visitors, Its working well I've added sys.argv to run it on network with help Alexey it work
Script:
Code: [Select]
import PhotoScan
import sys

#starting photoscan
app = PhotoScan.Application()
path = sys.argv[1]
#doc = PhotoScan.Document()
doc = PhotoScan.app.document
doc.open(path)
print("start process")

client = PhotoScan.NetworkClient()
#mon_path = PhotoScan.app.getExistingDirectory("dir")
task = PhotoScan.NetworkTask()
for c in doc.chunks:
#    task.chunks.append(c.key )
    task.frames.append((c.key, 0))
task.name = "BuildModel"
#task.params['apply'] = task.chunks
task.params['cameras'] = task.frames
#task.params['faces'] = "high"
#task.params['classes'] = [PhotoScan.PointClass.Ground]
task.params['surface'] = PhotoScan.Arbitrary
task.params['interpolation'] = PhotoScan.EnabledInterpolation
task.params['face_count'] = 1000
task.params['source'] = PhotoScan.DataSource.DenseCloudData
task.params['network_distribute'] = True #fine level task distribution key

path = "F:/TEST_PHOTOSCAN/toto2.psx" #relative path from root folder
client.connect('192.168.0.123') #server ip
batch_id = client.createBatch(path, [task])

client.resumeBatch(batch_id)
print("end")
   
And batch file example:
Code: [Select]
cd "c:\Program Files\Agisoft\PhotoScan Pro"
photoscan.exe -r F:\piotrwork\ps_network\hhh.py "F:\TEST_PHOTOSCAN\toto2.psx"

:-) :-)

9
Python and Java API / Re: Run script from batch file
« on: August 01, 2018, 05:19:07 PM »
I've added as You said and works well
Thank You Alexey

10
Python and Java API / Re: Run script from batch file
« on: July 31, 2018, 10:05:55 AM »
I've tried this combination and does not work,
Photoscan is on, my project is charged but script still not run
Have no idea how to run it I've tried whole day yesterday ...

11
Python and Java API / Run script from batch file
« on: July 30, 2018, 01:51:44 PM »
Hi all ,
How we can run a script from bat file ? I've tried few combination and nothing works , my photoscan start my project is charged, but there is no action after, script does not want run how can I charge it ??
Code: [Select]
cd "c:\Program Files\Agisoft\PhotoScan Pro"
photoscan F:\TEST_PHOTOSCAN\toto2.psx
photoscan F:\piotrwork\ps_network\network_combine_test.py
What I have to add over here to start my script ???

12
Python and Java API / Re: BuildModel params network
« on: July 30, 2018, 11:54:49 AM »
Hi Alexey
Works fine lovely , how I can start it from .bat file automatically ?? I have that
Code: [Select]
cd "c:\Program Files\Agisoft\PhotoScan Pro"
photoscan F:\TEST_PHOTOSCAN\toto2.psx  | photoscan.exe -r F:/piotrwork/ps_network/network_combine_test.py
??? How to overwrite it ?? My psx file is charged but script not work, first action is ok but I've got a disconnection from server , that what I have , script starts I can see first print and last one and disconnected from server, we have to add something to my script ???
my print from cmd
Code: [Select]
start process
connected to 192.168.0.123:5840
fin
disconnected from server

13
Python and Java API / BuildModel params network
« on: July 20, 2018, 05:53:15 PM »
Hi all,
I have a problem , I cant run my script , I want do BuildMesh and have errors
- Empty surface
- null frame
Did somebody can help I dont know witch parameters put to the function BuildModel nothing works Im on version 1.4.1

Code: [Select]
import PhotoScan

client = PhotoScan.NetworkClient()
doc = PhotoScan.app.document

task = PhotoScan.NetworkTask()
for c in doc.chunks:
    task.chunks.append(c.key )
    task.frames.append((c.key, 0))
task.name = "BuildModel"
task.params['apply'] = task.chunks
task.params['cameras'] = task.frames
#task.params['faces'] = "high"
#task.params['classes'] = [PhotoScan.PointClass.Ground]
task.params['surface'] = PhotoScan.Arbitrary
task.params['interpolation'] = PhotoScan.EnabledInterpolation
task.params['face_count'] = 1000
task.params['source'] = PhotoScan.DataSource.DenseCloudData
task.params['network_distribute'] = True #fine level task distribution key

path = "F:/TEST_PHOTOSCAN/toto2.psx" #relative path from root folder
client.connect('192.168.0.123') #server ip
batch_id = client.createBatch(path, [task])

client.resumeBatch(batch_id)
print("Debut")
Any help will be appreciated...

14
Python and Java API / Set a region from point A to B
« on: June 19, 2018, 12:39:49 PM »
Hi all
I'm looking for help , I have a probleme to set a region in my project from fixed points A to B, I have a text file with coordinates X,Y like this:
Code: [Select]
    {
        "Y": "131524.72623558177",
        "X": "600237.012492972"
    },
    {
        "Y": "131520.4597589273",
        "X": "600236.8305144551"
    },
    {
        "Y": "131516.19328227278",
        "X": "600236.6485359382"
    },
    {
        "Y": "131511.9268056183",
        "X": "600236.4665574214"
    }
What I'm looking for is to set a region box from 1st coordinates to 2nd (define by zone im my project to get the smallest parts) and do some stuff with , after get a 2nd region, from 2nd coordinates to 3rd (do some stuff with)etc etc
How to do it with python ?? to set my region ?? There is a lot infos over here http://www.agisoft.com/forum/index.php?topic=1886.15 or http://www.agisoft.com/forum/index.php?topic=2488.0
But I can't figured it out since few hours now  , how can I fix it ??? I've tried that but doesn't work at all ....
Code: [Select]
mySize = 4

#select the project
doc = PhotoScan.app.document

# Define: Map region
# MapRegionVec = [CenterX, CenterY, SizeX0, SizeY0, ZRotationDeg]
MapRegionVec = [coord_x, coord_y, mySize, mySize, 0.0]

#get the current chunk
chunk = doc.chunk

#create new region
newregion = PhotoScan.Region()

# Set region size
newregion.size = PhotoScan.Vector([MapRegionVec[2], MapRegionVec[3], chunk.region.size[2]])


# Set region rotation
# build rotation matrix in our coordinate system
RotZDeg = -MapRegionVec[4]
SinRotZ = math.sin(math.radians(RotZDeg))
CosRotZ = math.cos(math.radians(RotZDeg))
RotMat = PhotoScan.Matrix([[CosRotZ, -SinRotZ, 0, 0], [SinRotZ, CosRotZ, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])

#  Rotate region bounding box
T = chunk.transform.matrix
v = PhotoScan.Vector([0, 0, 0, 1])
v_t = T * v
v_t.size = 3
m = chunk.crs.localframe(v_t)
m = m * T
m = RotMat * m
s = math.sqrt(m[0, 0] ** 2 + m[0, 1] ** 2 + m[0, 2] ** 2)  # scale factor
R = PhotoScan.Matrix([[m[0, 0], m[0, 1], m[0, 2]], [m[1, 0], m[1, 1], m[1, 2]], [m[2, 0], m[2, 1], m[2, 2]]])
R = R * (1. / s)
newregion.rot = R.t()

# Put newregion to chunk
chunk.region = newregion

I've tried to pout my region center to one of my markers points and thats works , but did we can define a region possition between 2 points as I asked at the beginning of my post ???
Code: [Select]

# Define: Region [CenterX, CenterY, CenterZ, SizeX, SizeY, ZRotationDeg]
MapRegionVec = [600225.8792,131360.0026,67.30138399999889, 173.8, 143.6, -25.0]



# Set region center:
newregion = PhotoScan.Region()
centerUTM = PhotoScan.Vector([MapRegionVec[0], MapRegionVec[1], MapRegionVec[2]])
centerGEO = chunk.crs.unproject(centerUTM)
centerLocal = chunk.crs.localframe(centerGEO)


#newregion.center = PhotoScan.Vector([0,0,0])
newregion.size = PhotoScan.Vector([150,150,90])
chunk.region = newregion


#newregion.size = PhotoScan.Vector([MapRegionVec[3], MapRegionVec[4], chunk.region.size[2]])

# Set region rotation
import math
SinRotZ= math.sin(math.radians(MapRegionVec[5]))
CosRotZ= math.cos(math.radians(MapRegionVec[5]))
newregion.rot = PhotoScan.Matrix( [[SinRotZ,-CosRotZ,0], [CosRotZ,SinRotZ,0], [0,0,1]] )


# put newregion to chunk
chunk.region = newregion



15
I'ts ok I've got it  ;)
Code: [Select]
import os, PhotoScan
import datetime
chunk = PhotoScan.app.document.chunk
time_table = list()
for camera in chunk.cameras:
    time = camera.photo.meta['Exif/DateTimeOriginal'].split(" ")[1][:-3].replace(":", ".")
    time = float(time)
    time = time / 1 + (time  - time / 1) * 100 / 60
    interval = 08.03
    interval1 = 08.05
    start = interval
    if start <= time <= interval1:
        #print(start,time,interval1)
        camera.selected = True

Pages: [1] 2 3 4