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

Pages: [1]
1
Python and Java API / Re: Simple export undistorted images
« on: November 26, 2015, 10:35:55 PM »
that was it exactly.
Thank you so much for your help!

2
Python and Java API / Re: Simple export undistorted images
« on: November 26, 2015, 12:19:19 AM »
I get a false result. (but no errors)

3
Python and Java API / Re: Simple export undistorted images
« on: November 25, 2015, 10:06:57 PM »
Unfortunately I still can't get it to work. I have modified my code as follows:

Working code :

# photoscan doc
            doc = PhotoScan.app.document
           
            # create a new chunk in the workspace
            chunk = PhotoScan.app.document.addChunk()
 
            # add photos to the chunk
            #this adds them one at a time
            #need for loop to add 20 cameras at once

            chunk.addPhotos(["M:\TCL16\scans\D20\Session1\subject1\AU02_01\Captured_Photos\Tiff\FullColor\camera01_14.tif"])
           
            # Match Photos with accuracy setting and preselection
            chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection)
 
            # Align Photos
            chunk.alignCameras()
           
            #Build Dense Cloud
            chunk.buildDenseCloud(quality=PhotoScan.LowQuality)
 
            #surface setting = Arbitrary setting is part of the Build Mesh processing in the old Batch Processing menu
            #Interpolation is part of the advanced setting in Build Mesh job

            chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.Extrapolated)
           
            #Build Texture choice is blending mode and texture size (atlas height)
            #buildUV is mapping mode choice

            chunk.buildUV(mapping=PhotoScan.GenericMapping)
            chunk.buildTexture(blending=PhotoScan.MosaicBlending, size=1024)                   
                       
            # Export
            chunk.exportCameras("M:\TCL16\scans\D20\Session1\subject1\AU02_01\Scan_Data\subject1_01_ScanCameras.xml")
           
            #Export Model files (.jpg, .mtl, .obj)           
            chunk.exportModel("M:\TCL16\scans\D20\Session1\subject1\AU02_01\Scan_Data\subject1_01_ScanModel.obj")
 
After this code, I added:
               #need for loop to add 20 cameras at once
                camera = chunk.cameras[0] #first camera
                image = camera.photo.image()
                for camera in chunk.cameras:
                                currentCameraImage = camera.photo.image()
                                calibration = camera.sensor.calibration()
                                undistortedCameraImage = currentCameraImage.undistort(calibration, center_principal_point=buildSettings.exportData.undistortedPhotos.centerPrincipalPoints, square_pixels=buildSetting.exportData.undistortedPhotos.squarePixels)
                                undistortedFullImageName = os.path.split(camera.photo.path) [-1]
                                undistortedImageName = oc.path.plitext(undistortedFullImageName)

                                undistortedCameraImage.save(os.path.join(outputUndistortedDirPath, undistortedImageName +”.jpg”))
 
I hit enter twice, it returns:
Traceback (most recent call last):
File "<console>", line 3, in <module>
TypeError: 'PhotoScan.Calibration' object is not callable


I'm stuck at this point. It was suggested I can use the image.undistort() function after I have the image, with the arguments PhotoScan.Calibration() but I'm not sure what this should look like.

Thanks again for this help.
m

4
Python and Java API / Re: Simple export undistorted images
« on: November 25, 2015, 12:19:51 AM »
what worked in previous PS code:

for camera in doc.activeChunk.cameras:
        currentCameraImage = camera.image()
        undistortedCameraImage = currentCameraImage.undistort(camera.calibration,
                                                           center_principal_point=buildSettings.exportData.undistortedPhotos.centerPrinciplePoints,
                                                           square_pixels=buildSettings.exportData.undistortedPhotos.squarePixels)
        undistortedFullImageName = os.path.split(camera.path)[-1]
        undistortedImageName = os.path.splitext(undistortedFullImageName)[0]
        undistortedCameraImage.save(os.path.join(outputUndistortedDirPath, undistortedImageName + ".jpg"))


Error:

File "<console>", line 1
    for camera in doc.activeChunk.cameras:
        currentCameraImage = camera.image()
        undistortedCameraImage = currentCameraImage.undistort(camera.calibration,
                                                           center_principal_point=buildSettings.exportData.undistortedPhotos.centerPrinciplePoints,
                                                           square_pixels=buildSettings.exportData.undistortedPhotos.squarePixels)
        undistortedFullImageName = os.path.split(camera.path)[-1]
        undistortedImageName = os.path.splitext(undistortedFullImageName)[0]
        undistortedCameraImage.save(os.path.join(outputUndistortedDirPath, undistortedImageName + ".jpg"))
                                         
  ^
SyntaxError: invalid character in identifier

5
Python and Java API / Simple export undistorted images
« on: November 24, 2015, 09:41:13 PM »
HI all,
I'm a very new PhotoScan & Python user. I am in the process of switching over some Python code that works in older (?) PS1.1 to make it work in 1.2 and I'm stuck on something that should be fairly simple.

I am trying to export undistorted images from my chunk into a folder that I will create at the same time.
I see in the user manual for 1.2 that there is an undistort() command and Image.undistort(), but I'm stuck at how to actually use that in my code?

I have created the chunk and processed all my images, exported the model and cameras, and saved the project. This is my final step.

Any help for this beginner would be greatly appreciated.

Pages: [1]