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

Pages: [1] 2 3
1
Dear Paulo,

please apology, It is my mistakes for writing above mention comments. I want to correct it. I mean that when the center_principal_point=False, the depth pixel is not the same as RGB image. However, when the center_principal_point=True, it is well corresponding.

Best Regards,

LYHOUR

2
Dear Paulo,

I really appreciate your response. Thank you very much. However, I notice that from this line of this code, the center_principal_point should be True. I investigate that when the value is False, it is the same pixel position as the distort image. However, when I change it to true, the pixel of RGB and depth are corresponding nearly exactly (considering as same location) so It should be put the value to "True".
Code: [Select]
und_image = image.undistort(camera.sensor.calibration,center_principal_point=False, square_pixels=True)

3
Dear Paulo,

Thank you very much for your response and your explanation. How can I get the undistort RGB image ?

Best Regards,

LYHOUR

4
Dear Alexey,

Thank you very much for solving this problem I really appreciate your kindness for helping. Anyway do you check my above comment related to the pixel RGB corresponding to depth pixel ? I want to fix this problem. It would be better if you could help me on this.

Best Regards,

LYHOUR

5
Dear Alexey,

the statement : numpy.frombuffer(depth.tostring(), dtype=numpy.float32).reshape(height, width) is working only for F32. If I want to work with 8bit or 16 bit, it doesn't work due to three channel of img.convert to RGB. So what should I do ? Thank you very much.

Best Regards,
LYHOUR

6
Dear dwieka,

For install the external library or module to use in the Metashape, it can be use with this link https://agisoft.freshdesk.com/support/solutions/articles/31000136860-how-to-install-external-python-module-to-metashape-professional-package as the comment above. But it should be careful with the environment path that exists in your pc. For my experience, my python path or other path is conflict. I try to remove some environment path that unnecessary , then It worked.

7
Dear Alexey,
I really appreciate your kindness. I can solve it right now. Thank you very much. However, I face other problem when generate the depth map, the pixel of depth map and RGB image is not well corresponding. I will show you the figure in the attachment file. Noted that the figure I show you is cropped from the original for comparing the pixel location. However, when I evaluate the depth map from the the model.renderdepth, it generate well corresponding RGB pixel location and depth pixel location. But it take to long for computation time.

Best Regards,
LYHOUR

8
I use this function already. When I use it, it return the string very strange and I save to other file, it cannot work. Do I miss or something wrong ? Also, I might confuse the function numpy.frombuffer return only one dimensional array not two dimensional as the image height and width. I want to confirm that this function generate two dimensional array and save the depth value to the other file. I am sorry about your inconveniences and disturb your valuable time.

Best Regards,
LYHOUR

9
Dear Alexey,
Thank you very much for your kindly response and your script. I have been tried to modify the script already by creating the converting metashape image class to numpy array but it cannot achieve it. It would be better if you could guide me to adding the script.
Code: [Select]
for camera in camera_list:
    if camera in chunk.depth_maps.keys():
depth = chunk.depth_maps[camera].image()
if not F32:
img = numpy.frombuffer(depth.tostring(), dtype=numpy.float32)
depth_range = img.max() - img.min()
img = depth - img.min()
img = img * (1. / depth_range)
if self.formCmb.currentText() == "Grayscale 8-bit":
img = img.convert("RGB", "U8")
img = 255 - img
img = img - 255 * (img * (1 / 255))#normalized
img = img.convert("RGB", "U8")
elif self.formCmb.currentText() == "Grayscale 16-bit":
img = img.convert("RGB", "U16")
img = 65535 - img
img = img - 65535 * (img * (1 / 65535))#normalized
img = img.convert("RGB", "U16")
else:
img = depth * scale
#img.save(output_folder + "/" + camera.label + ".tif")
               # what should I put here to convert img to np array ? this is just my concept. It cannot work.
                  tmp = np.empty(shape=(img.width,img.height))
          for y in range(img.height):
      for x in range(img.width):
tmp[x,y] = img[x,y]
                 

Best Regards,

LYHOUR

10
Excuse me! I want to extract the depth data of selected camera. I have the python code which I found in the forum and also in the way to export depth in the GUI. However, The mentions method are save the depth data to the image file. I want to know is there any method to obtain the depth data and save to other file such as Matlab. Thank you very much.

11
Feature Requests / Re: The option to only generate depth maps.
« on: March 03, 2022, 12:58:13 PM »
Dear Wojtek and Mak11,

did you solve this problem ? if you solve it may you share me the script ?

Best regards

LYHOUR

12
Python and Java API / Re: How to remove gray flag from the marker detection
« on: February 09, 2022, 04:55:26 PM »
Dear Alex,

Thank you very much for your suggestion. I have no idea how to create the polygon from the maker. It would be better if you could show me some coding or documentation to create this. I am sorry about your inconvenience.

Best Regards,
LYHOUR

13
Python and Java API / Re: How to remove gray flag from the marker detection
« on: February 09, 2022, 03:53:58 PM »
Dear Alex,

Please apology, I am not so clear what you mentioned. If I am not confuse, the process you mentioned is conducted on the GUI. However, If I want to do in python code, how can I do it ? Because I generate the model using only Python.

Best Regards,

LYHOUR

14
Python and Java API / Re: How to remove gray flag from the marker detection
« on: February 09, 2022, 03:25:51 PM »
Dear Alex,

Thank you very much for your response. Actually, I need only four GCP. Then I process the python code to input the coordinate. I will show you the code and figure. First I rename the the GCP by sorting the coordinate. Then I put the coordinate depend on the label. If the gray flag occur, it is error on my algorithm. Therefore, It should be delete the gray flag by wrong detection. Alternatively, do you have any suggestion if I want only put the coordinate only 4 GCP in the cross code and disable or remove any wrong marker detection. thank you very much.

Best Regards,

LYHOUR

Code: [Select]
#---- rename the maker corresponding to coordinate by sort algorithm
xy_coord = list()
for marker in chunk.markers:
x_tmp,y_tmp,z_tmp = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
xy_coord.append([x_tmp,y_tmp])
tmp_coord = sorted(xy_coord, key=lambda k: [k[0], k[1]]) # sort coordinate base on x axis first.
k = 0
for i in range(len(tmp_coord)):
k += 1
for marker in chunk.markers:
x,y,z = chunk.crs.project(chunk.transform.matrix.mulp(marker.position))
if x == tmp_coord[i][0] and y == tmp_coord[i][1]:
marker.label = "gcp" + str(k)
break
#----- input the coordinate to the reference
for marker in chunk.markers:
if marker.label == "gcp1":
marker.reference.location = Metashape.Vector([0,0,0])
marker.reference.accuracy = Metashape.Vector([0.01,0.01,0.01])
marker.reference.enabled = True
elif marker.label == "gcp2":
marker.reference.location = Metashape.Vector([250,0,0])
marker.reference.accuracy = Metashape.Vector([0.01,0.01,0.01])
marker.reference.enabled = True
elif marker.label == "gcp3":
marker.reference.location = Metashape.Vector([0,250,0])
marker.reference.accuracy = Metashape.Vector([0.01,0.01,0.01])
marker.reference.enabled = True
elif marker.label == "gcp4":
marker.reference.location = Metashape.Vector([250,250,0])
marker.reference.accuracy = Metashape.Vector([0.01,0.01,0.01])
marker.reference.enabled = True

15
Python and Java API / How to remove gray flag from the marker detection
« on: February 09, 2022, 10:03:48 AM »
Excuse me everyone! I am using Autodetection Marker to detect the GCP with cross code (non code) as show in the figure. It work well for detection the GCP. However, it is over detection (gray flag) with non corresponding to the GCP. Therefore, How can i remove it using the python code ? Thank you very much.

Best Regards,
LYHOUR

Pages: [1] 2 3