Forum

Author Topic: some points are not unprojecting to cameras  (Read 2411 times)

arpit.p

  • Newbie
  • *
  • Posts: 17
    • View Profile
some points are not unprojecting to cameras
« on: June 21, 2024, 08:28:13 AM »
point = [x,y,Z]
    point_local = T.inv().mulp(chunk.crs.unproject(point))
    print(x,y,Z,point_local,defect_id,'poinnt_local')
    if len(point_local) < 2:
        continue
    count = 0
    for idx,camera in enumerate(chunk.cameras):
        #print(idx,'idx')
        #if idx==12:
            #break
        if not camera.transform:
            print('no transform')
            continue
        #print('camera',camera.label)
        try:
            x, y  = camera.project(point_local)
        except:
            print('camera')
            continue
        if (0 <= x < camera.sensor.width) and (0 <= y < camera.sensor.height):
            print(camera.label, str(x), str(y))
            count+=1
            print(count)
            if count == 1:
                print('making shape',point_local)
                P = surface.pickPoint(camera.center,camera.unproject(Metashape.Vector((x,y))))


I have been using this script to getting cameras from lat, long in orthophoto.
from around 40,000 points I don't get somewhere around 250-300 points found in cameras.

point_local = T.inv().mulp(chunk.crs.unproject(point))
x, y  = camera.project(point_local)
P = surface.pickPoint(camera.center,camera.unproject(Metashape.Vector((x,y))))

these 3 lines are null for these points. Any suggestions if I can get these points also as I understand not all the points on ortho are present in cameras.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #1 on: June 21, 2024, 03:41:55 PM »
Hello arpit.p,

What you are using as a "surface" in your script?

Maybe that surface has holes in the areas where the Point of interest is expected to be?
Best regards,
Alexey Pasumansky,
Agisoft LLC

arpit.p

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #2 on: June 24, 2024, 07:25:30 AM »
Thanks for the reply.
surface = chunk.dense_cloud
I am using dense cloud as my surface. Let's assume it has holes. Do I have any rectification for the same.
Or can I use orthophoto as a surface directly. Maybe not as shapes use elevation that's why dense cloud is needed.
« Last Edit: June 24, 2024, 07:27:18 AM by arpit.p »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #3 on: June 24, 2024, 01:21:07 PM »
Hello arpit.p,

Does it help, if you modify the last line as following:

Code: [Select]
P = surface.pickPoint(camera.center,camera.unproject(Metashape.Vector((x,y))))
if not P:
    P = chunk.tie_points.pickPoint(camera.center,camera.unproject(Metashape.Vector((x,y))))


Alternatively, based on the project needs, you can generate DEM with extrapolated option and then get Z based on XY value:
Code: [Select]
altitude = chunk.elevation.altitude(Metashape.Vector([x,y]))
Best regards,
Alexey Pasumansky,
Agisoft LLC

arpit.p

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #4 on: June 24, 2024, 02:02:33 PM »
Thanks
I tried. But it gives the following error.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #5 on: June 24, 2024, 02:17:48 PM »
Hello arpit.p,

If you are using 1.x version, then try to modify chunk.tie_points to chunk.point_cloud
Best regards,
Alexey Pasumansky,
Agisoft LLC

arpit.p

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #6 on: June 24, 2024, 02:20:15 PM »
Thanks Alexey!!

I've been using chunk.point_cloud only initially, But I faced issues with accuracy like I was getting points shifted from actual location.
You only suggested me to go with chunk.dense_cloud.
I tried this, And I am getting those missing  points too now. But those are not accurate enough.
« Last Edit: June 24, 2024, 02:38:24 PM by arpit.p »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15029
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #7 on: June 24, 2024, 03:10:28 PM »
Hello arpit.p,

Have you tried to implement the suggested lines that only use tie points for pickPoint, when dense cloud doesn't give a result for this method?
Best regards,
Alexey Pasumansky,
Agisoft LLC

arpit.p

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: some points are not unprojecting to cameras
« Reply #8 on: June 24, 2024, 03:37:33 PM »
Yeah I tried it. When Dense Cloud doesn't give P value.
I've tried to get the point from chunk.point_cloud as I am using 1.X version of Agisoft Python.
It does give me points and I am able to make shapes now. But the position is shifted by 1-2 m from actual position. As this was very accurate in the case of dense_cloud surface pick point.