IndexError: list index out of range in class ImageSet #3
-
Hi. I'm very new to EasyIDP, so I have no idea this error is a bug or fault of my usage. Now I am following the tutorial in wiki: Basic Usage, and demo data is been used. In section 1.2.2 Transformer, I tried calling import sys
sys.path.insert(0, './EasyIDP')
from easyric.objects import Pix4D
from easyric.io import shp, geotiff, plot
from easyric.calculate import geo2raw, geo2tiff
import pyproj
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# root dir of demote data is under the current dir
project_path = "lotus_170525"
p4d = Pix4D(
project_path=project_path,
raw_img_path=f"{project_path}/photos",
project_name=project_path,
param_folder=f"{project_path}/params"
)
plots = p4d.read_shp3d(shp_path=f"{project_path}/roi/plots.shp", get_z_by='all', shp_proj=pyproj.CRS.from_epsg(4326))
img_dict = geo2raw.get_img_coords_dict(p4d, plots['N1W1'] - p4d.offset.np, method='pmat') Traceback (most recent call last):
File ".\test.py", line 26, in <module>
img_dict = geo2raw.get_img_coords_dict(p4d, plots['N1W1'] - p4d.offset.np, method='pmat')
File "./EasyIDP\easyric\calculate\geo2raw.py", line 171, in get_img_coords_dict
projected_coords = pmatrix_calc(param, points, im.name, distort_correct)
File "./EasyIDP\easyric\calculate\geo2raw.py", line 75, in pmatrix_calc
xyz = (xyz1_prime).dot(param.img[image_name].pmat.T)
File "./EasyIDP\easyric\objects.py", line 261, in __getitem__
return self.img[self.names.index(key)]
IndexError: list index out of range Taking a look into >>> len(p4d.img.names)
266
>>> len(p4d.img.img)
5 For now, I want to run my code and know the features of EasyIDP, I edited def __getitem__(self, key):
if isinstance(key, int): # index by photo name
return self.img[key]
elif isinstance(key, str): # index by photo order
- return self.img[self.names.index(key)]
+ return next(filter(lambda i: i.name == key, self.img), None)
elif isinstance(key, slice):
return self.img[key]
else:
print(key)
return None Thank you for your answer. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Dear seo, Thanks a lot for using this package and ask your questions. You don't need to change any source code, the problem is caused by: the pix4d project used 266 raw images to generate the dom, however, the dome data only has 5 images in it.
The simplest way to fix this problem, is downloading full raw images:
PS: In the easyidp v2.0, you can easily access previous data by #31 : import easyidp as idp
lotus = idp.data.Lotus()
# photos
lotus.photos
# projects
lotus.pix4d.project And the API has been significantly changed, please refer to the documentation for more details. |
Beta Was this translation helpful? Give feedback.
Dear seo,
Thanks a lot for using this package and ask your questions.
You don't need to change any source code, the problem is caused by: the pix4d project used 266 raw images to generate the dom, however, the dome data only has 5 images in it.
The simplest way to fix this problem, is downloading full raw images:
https://github.com/HowcanoeWang/EasyIDP.paper/releaseshttps://github.com/UTokyo-FieldPhenomics-Lab/EasyIDP/releases/tag/v0.1-alphaOnlylotus_170525/photos
folder is needed, you don't have to download full 12GB data.PS: In the easyidp v2.0, you can easily access previous data by #31 :