Forum

Author Topic: Point cloud generation based on imported cameras and masks  (Read 3281 times)

Jitsu

  • Newbie
  • *
  • Posts: 3
    • View Profile
Point cloud generation based on imported cameras and masks
« on: June 27, 2018, 12:49:50 PM »
Hello,

currently I try to automate a process to import camera orientations and to calculate the sparse pointcloud using masks.

If I import the cameras via the GUI and then calculate the sparse pointcloud via "Build Dense Cloud", the imported masks are applied without problems and the result is as expected.
Using Python, however, the masks are not applied when generating the sparse pointcloud.

My procedure looks like this:

...
chunk.importCameras(path,format=PhotoScan.CamerasFormatXML)
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, filter_mask=True)
chunk.buildPoints()

I am pleased about Feedback.


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #1 on: July 01, 2018, 06:27:48 PM »
Hello Jitsu,

Have you imported the masks to the project in your script somewhere before the image matching operation? Can you share the code that is performing masks import operation?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Jitsu

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #2 on: July 02, 2018, 10:20:38 AM »
Hello Alexey,

the masks are imported before. I calculate a model (Low Quality) and use this as the basis for the masking operation. For a better result, I recalculate the process, but this time using the masks.

The same process through the GUI works fine. Only through Python does it seem that the masks are ignored because the sparse point cloud also contains the points outside the masked area.

Here is my code:

Code: [Select]
       
        # import exterior orientation and create mask from model
        chunk.importCameras(tmp+'/Kameras.xml',format=PhotoScan.CamerasFormatXML)
        chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, filter_mask=False, keypoint_limit=40000, tiepoint_limit=4000)
        chunk.buildPoints()
       
        #define Bounding Box
        createBB(chunk)
       
        chunk.buildDepthMaps(quality=PhotoScan.LowQuality, filter=PhotoScan.AggressiveFiltering)
        chunk.buildDenseCloud()
        chunk.buildModel(surface=PhotoScan.Arbitrary, interpolation=PhotoScan.EnabledInterpolation)
       
        chunk.importMasks('', source=PhotoScan.MaskSourceModel, operation=PhotoScan.MaskOperationReplacement, tolerance=10,cameras=chunk.cameras)

       
        # import exterior orientation and new calculation with masks
        chunk.importCameras(tmp+'/Kameras.xml',format=PhotoScan.CamerasFormatXML)
       
        chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=False, filter_mask=True)
       
        chunk.buildPoints()
        ...



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #3 on: July 02, 2018, 01:36:07 PM »
Hello Jitsu,

I think that the second matching is not performed, since the images are already matched. You need to remove the sparse point cloud before re-matching the image set in the same chunk:

Code: [Select]
chunk.point_cloud = None
chunk.matchPhotos(filter_mask = True)
Best regards,
Alexey Pasumansky,
Agisoft LLC

Jitsu

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #4 on: July 02, 2018, 02:32:42 PM »
Hello Alexey,

you're right with your guess.

Many Thanks!  :)


otepmong

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #5 on: August 15, 2018, 02:20:26 PM »
Hello Alexey,

I am trying to get  importCameras flow to work.  I follow the steps detailed here (except for masks), but the mesh/point cloud output is split into 3 blobs located outside the cameras location.

1. First I ran the script and exportMarkers and exportCameras
2.  As a test, I tried to importMarkers and importCameras with the same photos.   I had to bypass the bounding box code to avoid  'zero point' error.

There are region center, size, and R values in the exportCameras.  Can I use them unaltered ?

Script and example exportCameras.xml are attached.

Any pointers will be greatly appreciated.




Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #6 on: August 15, 2018, 07:41:40 PM »
Hello otepmong,

If you are trying to import the cameras from the XML, then you should use:
chunk.matchPhotos, chunk.importCameras, chunk.buildPoints

I can't find buildPoints in your code. Can you please add it to the section where the cameras are loaded and check, if there are any further issues.
Best regards,
Alexey Pasumansky,
Agisoft LLC

otepmong

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #7 on: August 15, 2018, 10:38:03 PM »

Hello Alexey,

Thank you for your quick reply.

My script did not use chunk.buildPoints.   In normal mode (not importCameras), it goes directly to  chunk.buildDepthMaps and  chunk.buildDenseCloud after chunk.matchPhotos and chunk.alignCameras .


For import cameras mode,  Is this correct;  chunk.matchPhotos, chunk.importCameras, chunk.buildPoints and then chunk.buildDepthMaps, chunk.buildDenseCloud ?

Do I need to add chunk.buildPoints to normal mode as well?

Thank you again for your help.


otepmong

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #8 on: August 18, 2018, 10:36:18 PM »

Hello again Alexey,

I added chunk.Buildpoints() as you suggested and it worked.  I was able to build the original model  (that exported marker lucy_markerref_081318.xml and camera xml files) by importing them back in.

However, I cannot use the marker or camera xml to build a different object even though the marker and camera are the same.  I got 'zero point' error,  the script was not able to compute markers' position.

Next I ran the new object, exported marker and camera xml files (stripedress_markerref.xml), and built the new model.  I can successfully imported the new marker and camera xml files and used on the new model.

So far I can only use the marker and camera reference on its own model, but not on any other.

I compare the two marker xml files (see attached), the location of the markers per  each camera, they seem to be the same. The only different between the two files is that the first marker xml file has more camera for each marker.

Please advise.


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #9 on: August 19, 2018, 04:51:40 PM »
Hello otepmong,

Do camera and marker labels are the same in both projects - the one that is used as a reference (where from XML is exported) and a new one (where to the XML is imported)?
Best regards,
Alexey Pasumansky,
Agisoft LLC

otepmong

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #10 on: August 19, 2018, 09:37:21 PM »

Hello Alexey,

Yes, there are.  Please see xml files attached to the previous message.  The number of camera ids listed under each marker is different.  If the camera ids match, the x, y coordinate seems to match. 

Thank you for your help.

otepmong

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Point cloud generation based on imported cameras and masks
« Reply #11 on: September 11, 2018, 09:44:30 PM »
Hello Alexey,

This still is not working for me.  Please advise.

Thank you.

Oh