Forum

Author Topic: Nonetype object is not subscriptable  (Read 4479 times)

sachapg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Nonetype object is not subscriptable
« on: March 12, 2016, 07:31:17 PM »
Hello everyone, i'm a student in digital imaging and i have to work on a photoscan project. The purpose of this project is to extract one part of my point cloud but i'm confronted with an issue : i can not access to the tuple of 2D coordinates returned by the function project in the PhotoScan.Cameras class. The sent-back message is the one in the title. I'm new to the python community and to the photoscan's aswell, and i'm french so please be the kindest you can :D

Thank you in advance, and sorry for my english

There is my code :

for index_cam in range(0, len(cameras)):
   
    image = cameras[index_cam].photo.image()
    height = image.height
    width = image.width
    path = cameras[index_cam].photo.path

    for index_points in range(0, len(selected_points)):
   
        project = cameras[index_cam].project(selected_points[index_points].coord)
   
        if (0 <= project[0] <= image.width and 0 <= project[1] <= image.height and index_points == len(selected_points) - 1):
            listPhotos.append(path)
        else:
            break
« Last Edit: March 12, 2016, 07:34:08 PM by sachapg »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14860
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #1 on: March 12, 2016, 08:27:35 PM »
Hello sachapg,
 
Can you also post an error message from the Console pane?
Best regards,
Alexey Pasumansky,
Agisoft LLC

sachapg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #2 on: March 13, 2016, 04:51:37 PM »
Hi my problem is solved i just had to add a condition :  if (project != None).
But i have an issue : my teacher told me to use the 'unproject' function of a camera to find the direction from a pixel to the point cloud and to see if there is an intersection between my plan defined my 2 markers on the point cloud and my straight line defined by my direction, but i don't know how i can use this function.
I used the sensor.unproject function but the returned vector is the same for all the cameras. I think it must return a normal vector of the plan defined by my camera
ty in advance

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14860
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #3 on: March 13, 2016, 05:14:51 PM »
Hello sachapg,

Using camera.sensor.unproject() function you'll get the vector going through the camera center and given point. But since the vector is in the camera coordinates you need to multiply it by camera.transform matrix to get the coordinates in the internal chunk's coordinate system.
Best regards,
Alexey Pasumansky,
Agisoft LLC

sachapg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #4 on: March 13, 2016, 05:21:08 PM »
Oh ok thank you.
The point i give to the function is the coordinate of the pixel considered in the camera's coordinate system, or the pixel's number in the image's data ? ( i mean for example : the first pixel of the image is (0,0) and the last = (width, height). Don't know if you can understand me.
And the camera center is the center of the image ?
thank you for your replies

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14860
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #5 on: March 13, 2016, 05:59:02 PM »
Hello sashapg,

Camera center is not the center of the 2D image frame, I have put it for the perspective center.

The coordinate system, though, is described correctly, except the fact that bottom right corner will have (width - 1, height - 1) coordinates.

For camera.sensor.unproject() function you need to pass the coordinates of the pixel in 2D space, like described above.
Best regards,
Alexey Pasumansky,
Agisoft LLC

sachapg

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Nonetype object is not subscriptable
« Reply #6 on: March 13, 2016, 06:41:42 PM »
Are you saying that photos are matched like on the image below? I thought points were projected following the normal vector of the camera plan, didn't think lines were crossed. So THIS is the perspective center ? I'm beginning to understand much better the software now, thank you