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

Pages: [1] 2 3 ... 9
1
Hi there,

I'm trying to output a rendered depthmap for specific coordinates, and was hoping to achieve that with "renderdepth" pointing at the point cloud... however based on my tests it seems like this just outputs a rendered image of the colored dense cloud, with the same behavior as renderImage. Is this the expected behavior or am I doing it wrong?

my code to export a depthmap of the PC:
Code: [Select]
    depth = chunk.dense_cloud.renderDepth(t, my_sensor_calibration, point_size=1, resolution=1, cull_points=False, add_alpha=True)
    image.save(root_export_folder + str(name) +"_depth.png")

To render an image of the PC:
Code: [Select]
image = chunk.dense_cloud.renderImage(t, my_sensor_calibration, point_size=dense_pc_size_for_export, resolution=1, cull_points=True, add_alpha=True)
    image.save(root_export_folder + str(name) +".png")

[/s]


Nope, my bad... I messed up the assignment of the images  ;D

2
Python and Java API / Re: problem with license activation in 1.8.1
« on: February 28, 2022, 07:15:26 PM »
Damn that was silly, thanks  ;D

3
Python and Java API / problem with license activation in 1.8.1
« on: February 28, 2022, 04:24:23 PM »
Hey there,

I have an installed version of 1.8.1 activated with a full license on my machine. Now I'm trying to manipulate some files without the GUI using the stand-alone python lib.
This worked previously with version 1.8.0 on the same machine.

Now since I updated the lib I get "No license found."  Ok, so I tried to activate in a python script by calling
Code: [Select]
Metashape.License.activate('xxxxxxxxxxxxx')

And I get this error:

Code: [Select]
TypeError: descriptor 'activate' for 'Metashape.Metashape.License' objects doesn't apply to a 'str' object
Based on the docs it seems like I should be passing a string:

Code: [Select]
class Metashape.License
License information.
activate(license_key)
Activate software online using a license key.
Parameters key (string) – Activation key.


Any ideas what I am missing here?

Cheers,

4
Python and Java API / Re: where is image quality stored?
« on: February 24, 2022, 04:53:06 PM »
Sorry, my bad, the variable is stored at:

camera.meta['Image/Quality'] !

5
Python and Java API / where is image quality stored?
« on: February 24, 2022, 04:48:29 PM »
Hi guys,

I'm looking for the metadata value that used to be stored under camera.meta["Quality"]  after calling chunk.analyzePhotos(camera) ... it seems like it's no longer there? I can't find where to look from the API docs.

Cheers,
Stephan

6
Feature Requests / Lighting in "renderImage"
« on: February 23, 2022, 03:20:33 PM »
Hey there,

I'd love to have the ability to create a spot light / directional light / point light or something similar to light textured meshes, and have this light be activated / deactivated via API when calling chunk.model.renderImage()

Cheers!
Stephan

7
Python and Java API / Re: Creating virtual cameras
« on: February 23, 2022, 03:19:03 PM »
Awesome thanks!
I the end I built my own system to do this but your code helped me understand a lot better!

8
Python and Java API / Re: Creating virtual cameras
« on: February 19, 2022, 08:52:01 PM »
I've made a lot of progress in understanding the coordinate system.
I'm still getting stuck on camera rotation / position however. I have no problem defining the locations that I want inside my chunk coordinate system (verified by putting markers in the locations)...

I stumbled upon the code from this thread for rendering an image:
https://www.agisoft.com/forum/index.php?topic=12545.msg55685#msg55685


This is the extract:
Code: [Select]
import Metashape

chunk = Metashape.app.document.chunk
T = chunk.crs.localframe(chunk.transform.translation) * chunk.transform.matrix

location = chunk.region.center + chunk.region.rot * chunk.region.size
direction = (chunk.region.center - location).normalized()
vertical = T.inv().mulv(Metashape.Vector([0, 0, 1]))

horizontal = Metashape.Vector.cross(direction, vertical).normalized()
vertical = Metashape.Vector.cross(direction, horizontal).normalized()
R = Metashape.Matrix([horizontal, vertical, direction])

cameraT = Metashape.Matrix().Translation(location) * Metashape.Matrix().Rotation(R.t())

image = chunk.model.renderImage(cameraT, chunk.sensors[0].calibration)
image.save("c://Work//render2.jpg")


The part I don't fully understand is this:

Code: [Select]
horizontal = Metashape.Vector.cross(direction, vertical).normalized()
vertical = Metashape.Vector.cross(direction, horizontal).normalized()
R = Metashape.Matrix([horizontal, vertical, direction])

What is going on here?
From what I understand we are calculating a component vector that corresponds to the components of the orientation in the chunk's internal reference frame? But I don't get how these lines work individually...



9
Python and Java API / Re: Creating virtual cameras
« on: February 19, 2022, 07:26:26 PM »
Thanks, that's very helplful Paulo!

10
Python and Java API / Re: Creating virtual cameras
« on: February 18, 2022, 05:03:46 PM »
I'm still confused and I can't get this to work... I think there is something I fundamentally and getting wrong with the way Photoscan creates rotation angles...

Code: [Select]
orientation = ps.Vector((7.997216319444453,55.883424713290765,-4.79245619778298)) # orientation vector Yaw, Pitch, Roll in chunk.crs

In the line of code above, am I right in assuming that the values should be in degrees? so (0,0,-90) should be straight down, correct? Or am I getting this confused?


11
Python and Java API / Re: Creating virtual cameras
« on: February 18, 2022, 03:25:49 PM »
Hi Paul,
That's very helpful, thanks!


12
Python and Java API / Re: Creating virtual cameras
« on: February 17, 2022, 04:52:39 PM »
Hi Alexey,

I've been working with chunk.model.renderImage() but I have a question: what is the format of the camera matrix that is expected for the first argument?
I mean: I can use the transform matrix of an existing camera, and this works, but I am interested in understanding the format of this matrix in order to be able to create my own parameters procedurally. Is there any documentation on this somewhere?

Cheers,
Stephan

13
Bug Reports / Re: Memory leak? in 1.8 and 1.8.1 on linux
« on: February 17, 2022, 10:49:52 AM »
Hi Alexey,

Unfortunately I cannot share the code, but these are the basic steps:

First active chunk has a sparse point cloud with 50K cameras aligned.

1. duplicate first active chunk and switch active chunk to the new duplicate
2. split work area into X parts on one axis and Y parts on another axis, jump to area Z and resize work area to fit this subsection of the main chunk
3. calculate matches
4. build dense PC (Colorized)
5. Make mesh from complete PC
6. calculate camera distances based on GPS coordinates and keep only the X closes cameras (500 usually) -> is this filling up memory?
7. reduce overlap (3)
8. build UV(generic mapping, page count 1)
9. build texture (mosaic blending, fill holes True, ghosting filter True)
10. Classify dense point cloud (based on classes) / export classes to separate PLY files on disk
11. remove keypoints outside of the work area from the chunk (based on distance calculation)

+ there are a number of optional steps that can happen, meshing the exported PC, remerging the tiles, basically making a semantic map at the same time as the main map, but I don't use these all the time and in this case I have deactivated them all to have just the basic steps above.


--> All of this runs fine actually, but I just need to restart the process every 2 or 3 days on a computer with 128Gb of RAM because it gradually fills up over processing (specifying in my script to start at chunk X + Z to carry on where it left off).

It's not the end of the world but it's annoying because the complete process with 50K cameras would take about 10 days if I could just let it run by itself without restarting, but because of these restarts I am loosing a few days.

Cheers,
Stephan

14
Python and Java API / Re: Creating virtual cameras
« on: February 16, 2022, 04:51:50 PM »
Thanks Alexey, I will give that a try!

15
Python and Java API / Creating virtual cameras
« on: February 15, 2022, 06:59:02 PM »
Hi there,
I'm trying to create some virtual cameras at locations specified by point coordinates over my mesh, in order to use these cameras to export images of the mesh.

To create these cameras I'm trying this:

Code: [Select]
i = 0
for point in points:
    tmp_sensor = chunk.addSensor()
    tmp_sensor.label = str(i)
    tmp_sensor.location = Metashape.Vector(point)
    tmp_sensor.location_enabled = True
    tmp_sensor.rotation = Metashape.Vector([0,0,0])
    tmp_sensor.rotation_enabled = True
    chunk.addCamera(tmp_sensor)
    i+-1

However it seems I cannot assign a location to a sensor in this way:

Code: [Select]
2022-02-15 16:56:26 Error: 'Metashape.Sensor' object attribute 'location' is read-only
Does anyone know what the correct way to create such virtual sensors might be?

Thanks!

Pages: [1] 2 3 ... 9