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 - fabvin

Pages: [1]
1
Python and Java API / Transformation type in fiducials marks
« on: November 23, 2023, 11:10:00 AM »
Dear all,
I would like to change the transformation type [Affine, Conformal, Projective] before fiducial calibration, but I didn't find the corresponding command in the metashape (2.0.3) python reference guide.
Do you have an idea?
Best regards
Fabrice

2
Python and Java API / Enable fiducial search
« on: November 17, 2023, 03:12:13 PM »
Dear all,
I wanted to create a code to detect fiducials in scanned images on all chunks of a metashape project, but I need to know the python code to enable the detection of fiducials (as in tools, Camera calibration, Film camera with fiducial marks):

def detect_fiducials():
    doc =scan.app.document
    for chk_sel in doc.chunks:
       code to enable fiducial detection
      chk_sel.detectFiducials(generate_masks=True,generic_detector=True)

Best regards

3
General / Error Empty pairs list
« on: December 19, 2021, 02:07:22 PM »
Hello,
Running on version 1.7.5 build 13229, I get the error message "Empty pairs list" when trying to merge two aligned chunks. Reading the topics https://www.agisoft.com/forum/index.php?topic=13261.0 and https://www.agisoft.com/forum/index.php?topic=12867.msg57033#msg57033 did not allow me to find the answer to the problem.

My goal seems to be quite simple: I need to add a new set of images to an already aligned chunk.
Here is my process:
* select Keep Key point in the Preference/advanced
* align the chunk 1
* add new cameras to a new chunk: chunk 2
* align the chunk 2
* merge the two chunks (Here is the problem: Error Empty pairs list)
Consequently, I have no key points in the pictures of the chunk 2 in the merged chunk.

Unfortunately, when I add directy the new pictures to the chunk 1 and I select Align Photos with  the box "reset current alignment" unchecked, it doesn't work because I haven't any stored key points in the new pictures.

Best regards
Fab

4
Bug Reports / Display of additionnal chunk in Classic Theme
« on: December 07, 2020, 12:21:52 PM »
Dear all
I observed that the display of an additionnal chunk created using the python script mergeChunk appeared in the Dark Theme of the console, but not in the classical theme (Metashape version 1.6).
Best regards

5
Python and Java API / Import camera GPS position
« on: December 02, 2020, 07:59:25 PM »
Dear all
I wanted to know how to properly import GPS positioning of a set of images using a csv file with, in columns: label, East, North?
Thank you in advance for your answer.
Best regards
Fab

6
Python and Java API / Pixel to 3D code very slow
« on: November 20, 2020, 03:20:25 PM »
Dear all
I proposed a code (below) to extract world 3D coordinates from image pixels of each image of an already aligned chunk.

The code works well, but is extremly long, even if I sample the pixels of the images (about 2 hours/image). Have you an idea on how to speed it up?
Best regards
FabVin


Code: [Select]
import Metashape, math, os, csv

# Pixel coordinates to 3D coordinates
def pixel_to_point3D(imX,imY):
    point2D = PhotoScan.Vector([imX, imY])
    sensor = camera.sensor
    v = chunk.model.pickPoint(camera.center, camera.transform.mulp(sensor.calibration.unproject(point2D)))
    if(v==None):return None
    v_t = chunk.transform.matrix.mulp(v)
    v_t.size = 3
    v_out_world = chunk.crs.project(v_t)
    return v_out_world

# Create a sequence of numbers
def seq(start,stop,increment):
    n=list()
    for num in range(start,stop):
        if num % increment == 0:
            n.append(num)
            continue
        pass
    return n

doc=PhotoScan.app.document

shift=PhotoScan.Vector([727290,6265210,70])

for chunk in doc.chunks:
    for camera in chunk.cameras:
        with open(path+'OUT/COORDS/'+chunk.label+'/'+camera.label.split(".")[0]+'.csv', 'wt') as csvfile:
            spamwriter=csv.writer(csvfile,delimiter=',',quotechar='|',quoting=csv.QUOTE_NONE,lineterminator='\n')
            for y in seq(0,6016,50):
                for x in seq(0,4000,50):
                    result=pixel_to_point3D(x,y)
                    if(result != None):
                        result=result-shift
                        spamwriter.writerow([x]+[y]+[round(result[0],3)]+[round(result[1],3)]+[round(result[2],3)])


7
Python and Java API / Problem with mergeChunks on list of chunks
« on: November 08, 2020, 12:48:43 AM »
Dear all
I get an error message : « Error : Empty chunk list » when I tried to use the command Metashape.app.document.mergeChunks(chunks=list_chunks_valid) where list_chunks_valid is a list of chunks defined above.

Event when I tried :
Metashape.app.document.mergeChunks(chunks=Metashape.app.document.chunks())

I get the same error message.

Did anyone try the mergeChunks command to a specified list of chunks ?
Best regards
Fabrice

8
General / Add new images to an already aligned chunk
« on: October 26, 2020, 12:59:39 AM »
Dear all,
I wanted to know if it is possible to add new images to an already aligned chunk, for example, when we process a chunk with a lot of images that took many times for alignment, then we took new pictures in the field to complete some parts of the chunk, and we want to keep the aligned images during the new alignment procedure.
Is there a way to do that, without considering the merging chunk options as we wanted to use the SIFT algorithm for aligning the new images on the existing chunk?
Best regards
FabVin


9
Python and Java API / Python script
« on: June 02, 2016, 05:46:27 PM »
Dear all,
Based on previous scripts from posts "Topic: region box translation after re-oriented", I created a function to set a bounding box according to a sextuplet of coordinates in a given coordinate system (in my case the EPSG:2154):

Code: [Select]
def set_box(xmin,xmax,ymin,ymax,zmin,zmax):
        doc=PhotoScan.app.document
        chunk=doc.chunk
        region = chunk.region
        r_center = region.center
        r_rotate = region.rot
        r_size = region.size
        x_scale = (xmax-xmin)/2
        y_scale = (ymax-ymin)/2
        z_scale = (zmax-zmin)/2
        new_region = PhotoScan.Region()
        new_rot = r_rotate
        new_center = PhotoScan.Vector([xmin+x_scale,ymin+y_scale,zmin+z_scale])
        new_center = chunk.transform.matrix.inv().mulp(chunk.crs.unproject(new_center))
        new_size = PhotoScan.Vector([x_scale * 5, y_scale * 5, z_scale * 5])
        #new_size = PhotoScan.Vector([x_scale, y_scale, z_scale])
        #new_size = chunk.transform.matrix.inv().mulp(chunk.crs.unproject(new_size))
        new_region.size = new_size
        new_region.center = new_center
        new_region.rot = new_rot
        chunk.region = new_region

However, the commented lines didn't work! When I tried them instead of the two previous ones, the bounding box disappears... I really don't understand why it doesn't work, as the new_center position looks right...

That's why I changed the two commented lines to get a box, but of course the size of the box is not correct.
Any help on the correct code is appreciated.

Best regards,
Fabrice

10
Python and Java API / Get chunk name
« on: January 20, 2016, 03:35:36 PM »
Dear all
I am wondering if it is possible to get the name of a chunk in a project, when running a loop on :

For example:

doc = PhotoScan.app.document
for chunk in doc.chunks:
      ??? chunk.name ???

Best regards

11
Python and Java API / Split in block for exportPoints function
« on: January 19, 2016, 08:29:51 PM »
Dear All,
Do you know if the "split in block" parameter had been implemented into the new exportPoints function in Photoscan 1.2.1 ?
I tried to used the arguments blockh and blockw but it didn't work.
Best regards,

12
Feature Requests / Add the command detectMarker in batch process
« on: March 15, 2015, 06:43:30 PM »
Dear Editor,
Is it possible to add the command detectMarkers in the batch process, in order to avoid spending time doing it for each chunk of a project?
Best regards

13
Python and Java API / Class PhotoScan.TargetType
« on: March 15, 2015, 06:40:18 PM »
Dear members,
I am trying to use Python scripting to automatize the detection of targets for every chunks of a Photoscan project, but the classes of the command TargetType looked wrong regarding the manual (PhotoScan Python Reference Release 1.1.0). They are called CircularTarget12bit on page 41 and TargetCircular12bit on page 16. I am trying to call the class Target Circular 16 bit, but none of the denominations TargetCircular16bit or CircularTarget16bit seemed to work.
Do you have an idea of the right denomination of the classes?

I have the latest version of Photoscan 1.1.3.

Best regards,

Pages: [1]