UTokyo-FieldPhenomics-Lab / EasyIDP

A handy tool for dealing with region of interest (ROI) on the image reconstruction (Metashape & Pix4D) outputs, mainly in agriculture applications
https://easyidp.readthedocs.io/en/latest/
MIT License
46 stars 6 forks source link

replace np.float with float, related to #80 #85

Closed bw4sz closed 1 year ago

bw4sz commented 1 year ago

Tests were failing with latest numpy version. Related to #80. I replaced all np.float with float. If you want np.float64 I can do that too.

Tested on numpy 1.24.2 1.24.2

pytest passes, except for a missing file

(BirdDetector) benweinstein@Bens-MacBook-Pro EasyIDP % pytest
==================================================================================================================== test session starts =====================================================================================================================
platform darwin -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/benweinstein/Documents/EasyIDP
collected 136 items

tests/test_cvtools.py ........                                                                                                                                                                                                                         [  5%]
tests/test_data.py ...                                                                                                                                                                                                                                 [  8%]
tests/test_geotiff.py .....................                                                                                                                                                                                                            [ 23%]
tests/test_init_class_func.py .....                                                                                                                                                                                                                    [ 27%]
tests/test_jsonfile.py ..                                                                                                                                                                                                                              [ 28%]
tests/test_metashape.py ....F.............                                                                                                                                                                                                             [ 41%]
tests/test_pix4d.py ..............                                                                                                                                                                                                                     [ 52%]
tests/test_pointcloud.py ........................                                                                                                                                                                                                      [ 69%]
tests/test_reconstruct.py ........                                                                                                                                                                                                                     [ 75%]
tests/test_roi.py .................                                                                                                                                                                                                                    [ 88%]
tests/test_shp.py ............                                                                                                                                                                                                                         [ 97%]
tests/test_visualize.py ....                                                                                                                                                                                                                           [100%]

========================================================================================================================== FAILURES ==========================================================================================================================
___________________________________________________________________________________________________________ test_class_init_metashape_multi_folder ___________________________________________________________________________________________________________

    def test_class_init_metashape_multi_folder():
        ms = idp.Metashape(project_path=test_data.metashape.multifolder_psx, chunk_id=0)

        assert ms.photos[0].label == "100MEDIA-DJI_0003"
        assert "100MEDIA/DJI_0003" in ms.photos[0].path

        # test run reverse calcuation
        # 1/30 size of square in the center of the full plot
        # export the chunk to aaa.ply, and read by open3d
        #
        # In [2]: pts = o3d.io.read_point_cloud("/Users/hwang/Desktop/aaa.ply")
        # In [4]: points = np.array(pts.points)
        # In [8]: xmin, ymin, z_min = points.min(axis=0)
        # In [9]: xmax, ymax, z_max = points.max(axis=0)
        # In [10]: xmean, ymean, z_mean = points.mean(axis=0)
        # In [11]: xlen = xmax- xmin
        # In [12]: ylen = ymax-ymin
        #
        # In [13]: xlen
        # Out[13]: 0.0045318603515625
        # In [26]: bf = xlen/30
        # In [27]: x0 = xmean - bf
        # In [28]: y0 = ymean -bf
        # In [29]: x1 = xmean + bf
        # In [30]: y1 = ymean + bf
        # In [31]: roi = np.array([[x0, y0, z0],[x0, y1, z0],[x1,y1,z0],[x1,y0,z0],[x0,y0,
        #     ...: z0]])
        # In [32]: roi
        # Out[32]:
        # array([[-120.87534231,   39.50387817, 1441.56202452],
        #        [-120.87534231,   39.50418029, 1441.56202452],
        #        [-120.87504018,   39.50418029, 1441.56202452],
        #        [-120.87504018,   39.50387817, 1441.56202452],
        #        [-120.87534231,   39.50387817, 1441.56202452]])

        roi = np.array(
            [[-120.87534231,   39.50387817, 1441.56202452],
             [-120.87534231,   39.50418029, 1441.56202452],
             [-120.87504018,   39.50418029, 1441.56202452],
             [-120.87504018,   39.50387817, 1441.56202452],
             [-120.87534231,   39.50387817, 1441.56202452]])

        out = ms.back2raw_crs(roi)

        assert len(out) == 40
        assert "100MEDIA-DJI_0099" in out.keys()

        # test_class_init_metashape_nested_folder
>       ms = idp.Metashape(project_path=test_data.metashape.nestedfolder_psx, chunk_id=0)

tests/test_metashape.py:148:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
easyidp/metashape.py:107: in __init__
    self.open_project(project_path, chunk_id)
easyidp/metashape.py:173: in open_project
    self._open_whole_project(project_path)
easyidp/metashape.py:264: in _open_whole_project
    _check_is_software(project_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = PosixPath('/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx')

    def _check_is_software(path: str):
        """Check if given path is metashape project structure

        Parameters
        ----------
        path: str
            e.g. proj_path="/root/to/metashape/test_proj.psx"

        Returns
        -------
        raise error if not a metashape projects (missing some files or path not found)
        """
        if not os.path.exists(path):
>           raise FileNotFoundError(f"Could not find Metashape project file [{path}]")
E           FileNotFoundError: Could not find Metashape project file [/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx]

easyidp/metashape.py:1266: FileNotFoundError
====================================================================================================================== warnings summary ======================================================================================================================
tests/test_metashape.py:428
  /Users/benweinstein/Documents/EasyIDP/tests/test_metashape.py:428: DeprecationWarning: invalid escape sequence \O
    '''

tests/test_cvtools.py::test_poly2mask_type_int
tests/test_cvtools.py::test_poly2mask_type_float
  /Users/benweinstein/Documents/EasyIDP/./easyidp/cvtools.py:275: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
    mask = _shapely_poly2mask(h, w, poly_coord)

tests/test_metashape.py::test_class_init_metashape
tests/test_metashape.py::test_class_init_metashape_warns_errors
tests/test_metashape.py::test_class_show_chunk
tests/test_metashape.py::test_class_back2raw_error
tests/test_roi.py::test_class_roi_back2raw_error
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:297: UserWarning: This project only has one chunk named [0] 'Chunk 1', ignore the wrong chunk_id [None] specified by user.
    warnings.warn(

tests/test_metashape.py::test_class_init_metashape_multi_folder
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:509: UserWarning: Have not specify the CRS of output DOM/DSM/PCD, may get wrong backward projection results, please specify it by `ms.crs=dom.crs` or `ms.crs=pyproj.CRS.from_epsg(...)`
    warnings.warn("Have not specify the CRS of output DOM/DSM/PCD, may get wrong backward projection results, please specify it by `ms.crs=dom.crs` or `ms.crs=pyproj.CRS.from_epsg(...)` ")

tests/test_metashape.py::test_class_init_metashape_warns_errors
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:304: UserWarning: The project has [4] chunks, however no chunk_id has been specified, open the first chunk [1] 'multiple_bbb' by default.
    warnings.warn(

tests/test_metashape.py::test_class_init_metashape_warns_errors
tests/test_metashape.py::test_class_show_chunk
tests/test_metashape.py::test_class_open_chunk_print
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:344: UserWarning: Current chunk missing required ['transform', 'sensors', 'photos'] information (is it an empty chunk without finishing SfM tasks?) and unable to do further analysis.
    warnings.warn(f"Current chunk missing required {missing_pool} information "

tests/test_pix4d.py::test_class_read_renamed_project
tests/test_pix4d.py::test_class_back2raw_single
tests/test_pix4d.py::test_class_back2raw_error
tests/test_pix4d.py::test_class_photos_get_by_short_name
tests/test_visualize.py::test_class_back2raw_single
  /Users/benweinstein/Documents/EasyIDP/./easyidp/pix4d.py:302: UserWarning: Could not find ['DJI_0151.JPG', 'DJI_0152.JPG', 'DJI_0153.JPG', 'DJI_0154.JPG', 'DJI_0155.JPG', 'DJI_0156.JPG', 'DJI_0157.JPG', 'DJI_0158.JPG', 'DJI_0159.JPG', 'DJI_0160.JPG', 'DJI_0161.JPG', 'DJI_0162.JPG', 'DJI_0163.JPG', 'DJI_0164.JPG', 'DJI_0166.JPG', 'DJI_0167.JPG', 'DJI_0170.JPG', 'DJI_0171.JPG', 'DJI_0172.JPG', 'DJI_0173.JPG', 'DJI_0175.JPG', 'DJI_0176.JPG', 'DJI_0177.JPG', 'DJI_0178.JPG', 'DJI_0179.JPG', 'DJI_0180.JPG', 'DJI_0181.JPG', 'DJI_0182.JPG', 'DJI_0183.JPG', 'DJI_0184.JPG', 'DJI_0185.JPG', 'DJI_0186.JPG', 'DJI_0187.JPG', 'DJI_0188.JPG', 'DJI_0189.JPG', 'DJI_0190.JPG', 'DJI_0191.JPG', 'DJI_0192.JPG', 'DJI_0193.JPG', 'DJI_0194.JPG', 'DJI_0195.JPG', 'DJI_0196.JPG', 'DJI_0202.JPG', 'DJI_0203.JPG', 'DJI_0204.JPG', 'DJI_0205.JPG', 'DJI_0206.JPG', 'DJI_0207.JPG', 'DJI_0208.JPG', 'DJI_0209.JPG', 'DJI_0210.JPG', 'DJI_0211.JPG', 'DJI_0212.JPG', 'DJI_0213.JPG', 'DJI_0214.JPG', 'DJI_0215.JPG', 'DJI_0216.JPG', 'DJI_0217.JPG', 'DJI_0218.JPG', 'DJI_0219.JPG', 'DJI_0220.JPG', 'DJI_0221.JPG', 'DJI_0222.JPG', 'DJI_0223.JPG', 'DJI_0224.JPG', 'DJI_0225.JPG', 'DJI_0226.JPG', 'DJI_0232.JPG', 'DJI_0233.JPG', 'DJI_0234.JPG', 'DJI_0235.JPG', 'DJI_0236.JPG', 'DJI_0237.JPG', 'DJI_0238.JPG', 'DJI_0239.JPG', 'DJI_0240.JPG', 'DJI_0241.JPG', 'DJI_0242.JPG', 'DJI_0243.JPG', 'DJI_0244.JPG', 'DJI_0245.JPG', 'DJI_0246.JPG', 'DJI_0247.JPG', 'DJI_0248.JPG', 'DJI_0249.JPG', 'DJI_0250.JPG', 'DJI_0252.JPG', 'DJI_0253.JPG', 'DJI_0254.JPG', 'DJI_0255.JPG', 'DJI_0256.JPG', 'DJI_0257.JPG', 'DJI_0258.JPG', 'DJI_0259.JPG', 'DJI_0260.JPG', 'DJI_0261.JPG', 'DJI_0262.JPG', 'DJI_0263.JPG', 'DJI_0264.JPG', 'DJI_0265.JPG', 'DJI_0266.JPG', 'DJI_0267.JPG', 'DJI_0268.JPG', 'DJI_0269.JPG', 'DJI_0270.JPG', 'DJI_0271.JPG', 'DJI_0272.JPG', 'DJI_0273.JPG', 'DJI_0274.JPG', 'DJI_0275.JPG', 'DJI_0276.JPG', 'DJI_0277.JPG', 'DJI_0278.JPG', 'DJI_0279.JPG', 'DJI_0280.JPG', 'DJI_0281.JPG', 'DJI_0282.JPG', 'DJI_0283.JPG', 'DJI_0284.JPG', 'DJI_0285.JPG', 'DJI_0286.JPG', 'DJI_0287.JPG', 'DJI_0288.JPG', 'DJI_0289.JPG', 'DJI_0290.JPG', 'DJI_0291.JPG', 'DJI_0292.JPG', 'DJI_0293.JPG', 'DJI_0294.JPG', 'DJI_0295.JPG', 'DJI_0296.JPG', 'DJI_0297.JPG', 'DJI_0298.JPG', 'DJI_0299.JPG', 'DJI_0300.JPG', 'DJI_0301.JPG', 'DJI_0302.JPG', 'DJI_0303.JPG', 'DJI_0304.JPG', 'DJI_0305.JPG', 'DJI_0306.JPG', 'DJI_0307.JPG', 'DJI_0308.JPG', 'DJI_0309.JPG', 'DJI_0310.JPG', 'DJI_0311.JPG', 'DJI_0312.JPG', 'DJI_0313.JPG', 'DJI_0314.JPG', 'DJI_0315.JPG', 'DJI_0316.JPG', 'DJI_0317.JPG', 'DJI_0318.JPG', 'DJI_0319.JPG', 'DJI_0320.JPG', 'DJI_0321.JPG', 'DJI_0322.JPG', 'DJI_0323.JPG', 'DJI_0324.JPG', 'DJI_0325.JPG', 'DJI_0326.JPG', 'DJI_0327.JPG', 'DJI_0328.JPG', 'DJI_0329.JPG', 'DJI_0330.JPG', 'DJI_0331.JPG', 'DJI_0332.JPG', 'DJI_0333.JPG', 'DJI_0334.JPG', 'DJI_0335.JPG', 'DJI_0336.JPG', 'DJI_0337.JPG', 'DJI_0338.JPG', 'DJI_0339.JPG', 'DJI_0340.JPG', 'DJI_0341.JPG', 'DJI_0342.JPG', 'DJI_0343.JPG', 'DJI_0344.JPG', 'DJI_0345.JPG', 'DJI_0346.JPG', 'DJI_0347.JPG', 'DJI_0348.JPG', 'DJI_0349.JPG', 'DJI_0350.JPG', 'DJI_0351.JPG', 'DJI_0352.JPG', 'DJI_0353.JPG', 'DJI_0354.JPG', 'DJI_0355.JPG', 'DJI_0356.JPG', 'DJI_0357.JPG', 'DJI_0358.JPG', 'DJI_0359.JPG', 'DJI_0360.JPG', 'DJI_0361.JPG', 'DJI_0362.JPG', 'DJI_0363.JPG', 'DJI_0364.JPG', 'DJI_0365.JPG', 'DJI_0366.JPG', 'DJI_0367.JPG', 'DJI_0368.JPG', 'DJI_0369.JPG', 'DJI_0370.JPG', 'DJI_0371.JPG', 'DJI_0372.JPG', 'DJI_0373.JPG', 'DJI_0374.JPG', 'DJI_0375.JPG', 'DJI_0376.JPG', 'DJI_0377.JPG', 'DJI_0378.JPG', 'DJI_0379.JPG', 'DJI_0380.JPG', 'DJI_0381.JPG', 'DJI_0382.JPG', 'DJI_0383.JPG', 'DJI_0384.JPG', 'DJI_0385.JPG', 'DJI_0386.JPG', 'DJI_0387.JPG', 'DJI_0388.JPG', 'DJI_0389.JPG', 'DJI_0390.JPG', 'DJI_0391.JPG', 'DJI_0392.JPG', 'DJI_0393.JPG', 'DJI_0394.JPG', 'DJI_0395.JPG', 'DJI_0396.JPG', 'DJI_0397.JPG', 'DJI_0398.JPG', 'DJI_0399.JPG', 'DJI_0400.JPG', 'DJI_0401.JPG', 'DJI_0402.JPG', 'DJI_0403.JPG', 'DJI_0404.JPG', 'DJI_0405.JPG', 'DJI_0406.JPG', 'DJI_0407.JPG', 'DJI_0408.JPG', 'DJI_0409.JPG', 'DJI_0410.JPG', 'DJI_0411.JPG', 'DJI_0412.JPG', 'DJI_0413.JPG', 'DJI_0414.JPG', 'DJI_0415.JPG', 'DJI_0416.JPG', 'DJI_0417.JPG', 'DJI_0418.JPG', 'DJI_0419.JPG', 'DJI_0420.JPG', 'DJI_0421.JPG'] in given raw_img_folder[{raw_img_folder}]
    warnings.warn(

tests/test_reconstruct.py::test_class_sensor_in_img_boundary
  /Users/benweinstein/Documents/EasyIDP/./easyidp/reconstruct.py:231: FutureWarning: This API `ignore` (str) will be enhanced and changed to `ignore_overflow` (bool) in the future.
    warnings.warn(

tests/test_reconstruct.py::test_class_sensor_in_img_boundary
  /Users/benweinstein/Documents/EasyIDP/./easyidp/reconstruct.py:246: FutureWarning: This API `ignore` (str) will be enhanced and changed to `ignore_overflow` (bool) in the future.
    warnings.warn(

tests/test_roi.py::test_class_roi_change_crs
tests/test_roi.py::test_class_roi_get_z_from_dsm_errors
tests/test_shp.py::test_read_shp_without_target
tests/test_shp.py::test_read_shp_proj_success_print
tests/test_shp.py::test_read_shp_key_names
tests/test_shp.py::test_convert_shp
  /Users/benweinstein/Documents/EasyIDP/./easyidp/shp.py:399: UserWarning: Not specifying parameter 'name_field', will using the row id (from 0 to end) as the index for each polygon.Please using idp.shp.show_shp_field(shp_path) to display the full available indexs
    warnings.warn(

tests/test_roi.py::test_class_roi_crop
  /Users/benweinstein/Documents/EasyIDP/./easyidp/pointcloud.py:828: UserWarning: Cropped 0 point in given polygon. Please check whether the coords is correct.
    warnings.warn("Cropped 0 point in given polygon. Please check whether the coords is correct.")

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================================================================================================================== short test summary info ===================================================================================================================
FAILED tests/test_metashape.py::test_class_init_metashape_multi_folder - FileNotFoundError: Could not find Metashape project file [/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx]
=================================================================================================== 1 failed, 135 passed, 27 warnings in 233.25s (0:03:53) =====================================================================================
FAILED tests/test_metashape.py::test_class_init_metashape_multi_folder - FileNotFoundError: Could not find Metashape project file [/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx]

Please consider making tests fully reproducible, then others can contribute more seemlessly. This is a great and important project that I hope the community can adopt.

HowcanoeWang commented 1 year ago

Thank you for helping solve this, Changing np.float to float should be a simple solution.

And for the data missing problem, could you try idp.data.TestData().reload_data() to update the cached data? Because we added some testing data several weeks ago.

bw4sz commented 1 year ago

Glad i could help. No updating cache doesn't change behavior.

(BirdDetector) benweinstein@Bens-MacBook-Pro EasyIDP % python
Python 3.9.5 (default, May 18 2021, 12:31:01)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from easyidp.data import TestData
>>> TestData().reload_data()
Downloading...
From (uriginal): https://drive.google.com/uc?id=17b_17CofqIuCVOWMnD67_wOnWMtwF8bw
From (redirected): https://drive.google.com/uc?id=17b_17CofqIuCVOWMnD67_wOnWMtwF8bw&confirm=t&uuid=dd84af17-10fa-4fdb-8a82-d6ee1fb61ced
To: /Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests.zip
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 337M/337M [00:13<00:00, 24.3MB/s]
Successfully downloaded, start unzipping ...
Successfully unzipped, the cache zip file has been removed.
>>> quit()
(BirdDetector) benweinstein@Bens-MacBook-Pro EasyIDP % pytest
==================================================================================================================== test session starts =====================================================================================================================
platform darwin -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/benweinstein/Documents/EasyIDP
collected 136 items

tests/test_cvtools.py ........                                                                                                                                                                                                                         [  5%]
tests/test_data.py ...                                                                                                                                                                                                                                 [  8%]
tests/test_geotiff.py .....................                                                                                                                                                                                                            [ 23%]
tests/test_init_class_func.py .....                                                                                                                                                                                                                    [ 27%]
tests/test_jsonfile.py ..                                                                                                                                                                                                                              [ 28%]
tests/test_metashape.py ....F.............                                                                                                                                                                                                             [ 41%]
tests/test_pix4d.py ..............                                                                                                                                                                                                                     [ 52%]
tests/test_pointcloud.py ........................                                                                                                                                                                                                      [ 69%]
tests/test_reconstruct.py ........                                                                                                                                                                                                                     [ 75%]
tests/test_roi.py .................                                                                                                                                                                                                                    [ 88%]
tests/test_shp.py ............                                                                                                                                                                                                                         [ 97%]
tests/test_visualize.py ....                                                                                                                                                                                                                           [100%]

========================================================================================================================== FAILURES ==========================================================================================================================
___________________________________________________________________________________________________________ test_class_init_metashape_multi_folder ___________________________________________________________________________________________________________

    def test_class_init_metashape_multi_folder():
        ms = idp.Metashape(project_path=test_data.metashape.multifolder_psx, chunk_id=0)

        assert ms.photos[0].label == "100MEDIA-DJI_0003"
        assert "100MEDIA/DJI_0003" in ms.photos[0].path

        # test run reverse calcuation
        # 1/30 size of square in the center of the full plot
        # export the chunk to aaa.ply, and read by open3d
        #
        # In [2]: pts = o3d.io.read_point_cloud("/Users/hwang/Desktop/aaa.ply")
        # In [4]: points = np.array(pts.points)
        # In [8]: xmin, ymin, z_min = points.min(axis=0)
        # In [9]: xmax, ymax, z_max = points.max(axis=0)
        # In [10]: xmean, ymean, z_mean = points.mean(axis=0)
        # In [11]: xlen = xmax- xmin
        # In [12]: ylen = ymax-ymin
        #
        # In [13]: xlen
        # Out[13]: 0.0045318603515625
        # In [26]: bf = xlen/30
        # In [27]: x0 = xmean - bf
        # In [28]: y0 = ymean -bf
        # In [29]: x1 = xmean + bf
        # In [30]: y1 = ymean + bf
        # In [31]: roi = np.array([[x0, y0, z0],[x0, y1, z0],[x1,y1,z0],[x1,y0,z0],[x0,y0,
        #     ...: z0]])
        # In [32]: roi
        # Out[32]:
        # array([[-120.87534231,   39.50387817, 1441.56202452],
        #        [-120.87534231,   39.50418029, 1441.56202452],
        #        [-120.87504018,   39.50418029, 1441.56202452],
        #        [-120.87504018,   39.50387817, 1441.56202452],
        #        [-120.87534231,   39.50387817, 1441.56202452]])

        roi = np.array(
            [[-120.87534231,   39.50387817, 1441.56202452],
             [-120.87534231,   39.50418029, 1441.56202452],
             [-120.87504018,   39.50418029, 1441.56202452],
             [-120.87504018,   39.50387817, 1441.56202452],
             [-120.87534231,   39.50387817, 1441.56202452]])

        out = ms.back2raw_crs(roi)

        assert len(out) == 40
        assert "100MEDIA-DJI_0099" in out.keys()

        # test_class_init_metashape_nested_folder
>       ms = idp.Metashape(project_path=test_data.metashape.nestedfolder_psx, chunk_id=0)

tests/test_metashape.py:148:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
easyidp/metashape.py:107: in __init__
    self.open_project(project_path, chunk_id)
easyidp/metashape.py:173: in open_project
    self._open_whole_project(project_path)
easyidp/metashape.py:264: in _open_whole_project
    _check_is_software(project_path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = PosixPath('/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx')

    def _check_is_software(path: str):
        """Check if given path is metashape project structure

        Parameters
        ----------
        path: str
            e.g. proj_path="/root/to/metashape/test_proj.psx"

        Returns
        -------
        raise error if not a metashape projects (missing some files or path not found)
        """
        if not os.path.exists(path):
>           raise FileNotFoundError(f"Could not find Metashape project file [{path}]")
E           FileNotFoundError: Could not find Metashape project file [/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx]

easyidp/metashape.py:1266: FileNotFoundError
====================================================================================================================== warnings summary ======================================================================================================================
tests/test_cvtools.py::test_poly2mask_type_int
tests/test_cvtools.py::test_poly2mask_type_float
  /Users/benweinstein/Documents/EasyIDP/./easyidp/cvtools.py:275: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
    mask = _shapely_poly2mask(h, w, poly_coord)

tests/test_metashape.py::test_class_init_metashape
tests/test_metashape.py::test_class_init_metashape_warns_errors
tests/test_metashape.py::test_class_show_chunk
tests/test_metashape.py::test_class_back2raw_error
tests/test_roi.py::test_class_roi_back2raw_error
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:297: UserWarning: This project only has one chunk named [0] 'Chunk 1', ignore the wrong chunk_id [None] specified by user.
    warnings.warn(

tests/test_metashape.py::test_class_init_metashape_multi_folder
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:509: UserWarning: Have not specify the CRS of output DOM/DSM/PCD, may get wrong backward projection results, please specify it by `ms.crs=dom.crs` or `ms.crs=pyproj.CRS.from_epsg(...)`
    warnings.warn("Have not specify the CRS of output DOM/DSM/PCD, may get wrong backward projection results, please specify it by `ms.crs=dom.crs` or `ms.crs=pyproj.CRS.from_epsg(...)` ")

tests/test_metashape.py::test_class_init_metashape_warns_errors
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:304: UserWarning: The project has [4] chunks, however no chunk_id has been specified, open the first chunk [1] 'multiple_bbb' by default.
    warnings.warn(

tests/test_metashape.py::test_class_init_metashape_warns_errors
tests/test_metashape.py::test_class_show_chunk
tests/test_metashape.py::test_class_open_chunk_print
  /Users/benweinstein/Documents/EasyIDP/./easyidp/metashape.py:344: UserWarning: Current chunk missing required ['transform', 'sensors', 'photos'] information (is it an empty chunk without finishing SfM tasks?) and unable to do further analysis.
    warnings.warn(f"Current chunk missing required {missing_pool} information "

tests/test_pix4d.py::test_class_read_renamed_project
tests/test_pix4d.py::test_class_back2raw_single
tests/test_pix4d.py::test_class_back2raw_error
tests/test_pix4d.py::test_class_photos_get_by_short_name
tests/test_visualize.py::test_class_back2raw_single
  /Users/benweinstein/Documents/EasyIDP/./easyidp/pix4d.py:302: UserWarning: Could not find ['DJI_0151.JPG', 'DJI_0152.JPG', 'DJI_0153.JPG', 'DJI_0154.JPG', 'DJI_0155.JPG', 'DJI_0156.JPG', 'DJI_0157.JPG', 'DJI_0158.JPG', 'DJI_0159.JPG', 'DJI_0160.JPG', 'DJI_0161.JPG', 'DJI_0162.JPG', 'DJI_0163.JPG', 'DJI_0164.JPG', 'DJI_0166.JPG', 'DJI_0167.JPG', 'DJI_0170.JPG', 'DJI_0171.JPG', 'DJI_0172.JPG', 'DJI_0173.JPG', 'DJI_0175.JPG', 'DJI_0176.JPG', 'DJI_0177.JPG', 'DJI_0178.JPG', 'DJI_0179.JPG', 'DJI_0180.JPG', 'DJI_0181.JPG', 'DJI_0182.JPG', 'DJI_0183.JPG', 'DJI_0184.JPG', 'DJI_0185.JPG', 'DJI_0186.JPG', 'DJI_0187.JPG', 'DJI_0188.JPG', 'DJI_0189.JPG', 'DJI_0190.JPG', 'DJI_0191.JPG', 'DJI_0192.JPG', 'DJI_0193.JPG', 'DJI_0194.JPG', 'DJI_0195.JPG', 'DJI_0196.JPG', 'DJI_0202.JPG', 'DJI_0203.JPG', 'DJI_0204.JPG', 'DJI_0205.JPG', 'DJI_0206.JPG', 'DJI_0207.JPG', 'DJI_0208.JPG', 'DJI_0209.JPG', 'DJI_0210.JPG', 'DJI_0211.JPG', 'DJI_0212.JPG', 'DJI_0213.JPG', 'DJI_0214.JPG', 'DJI_0215.JPG', 'DJI_0216.JPG', 'DJI_0217.JPG', 'DJI_0218.JPG', 'DJI_0219.JPG', 'DJI_0220.JPG', 'DJI_0221.JPG', 'DJI_0222.JPG', 'DJI_0223.JPG', 'DJI_0224.JPG', 'DJI_0225.JPG', 'DJI_0226.JPG', 'DJI_0232.JPG', 'DJI_0233.JPG', 'DJI_0234.JPG', 'DJI_0235.JPG', 'DJI_0236.JPG', 'DJI_0237.JPG', 'DJI_0238.JPG', 'DJI_0239.JPG', 'DJI_0240.JPG', 'DJI_0241.JPG', 'DJI_0242.JPG', 'DJI_0243.JPG', 'DJI_0244.JPG', 'DJI_0245.JPG', 'DJI_0246.JPG', 'DJI_0247.JPG', 'DJI_0248.JPG', 'DJI_0249.JPG', 'DJI_0250.JPG', 'DJI_0252.JPG', 'DJI_0253.JPG', 'DJI_0254.JPG', 'DJI_0255.JPG', 'DJI_0256.JPG', 'DJI_0257.JPG', 'DJI_0258.JPG', 'DJI_0259.JPG', 'DJI_0260.JPG', 'DJI_0261.JPG', 'DJI_0262.JPG', 'DJI_0263.JPG', 'DJI_0264.JPG', 'DJI_0265.JPG', 'DJI_0266.JPG', 'DJI_0267.JPG', 'DJI_0268.JPG', 'DJI_0269.JPG', 'DJI_0270.JPG', 'DJI_0271.JPG', 'DJI_0272.JPG', 'DJI_0273.JPG', 'DJI_0274.JPG', 'DJI_0275.JPG', 'DJI_0276.JPG', 'DJI_0277.JPG', 'DJI_0278.JPG', 'DJI_0279.JPG', 'DJI_0280.JPG', 'DJI_0281.JPG', 'DJI_0282.JPG', 'DJI_0283.JPG', 'DJI_0284.JPG', 'DJI_0285.JPG', 'DJI_0286.JPG', 'DJI_0287.JPG', 'DJI_0288.JPG', 'DJI_0289.JPG', 'DJI_0290.JPG', 'DJI_0291.JPG', 'DJI_0292.JPG', 'DJI_0293.JPG', 'DJI_0294.JPG', 'DJI_0295.JPG', 'DJI_0296.JPG', 'DJI_0297.JPG', 'DJI_0298.JPG', 'DJI_0299.JPG', 'DJI_0300.JPG', 'DJI_0301.JPG', 'DJI_0302.JPG', 'DJI_0303.JPG', 'DJI_0304.JPG', 'DJI_0305.JPG', 'DJI_0306.JPG', 'DJI_0307.JPG', 'DJI_0308.JPG', 'DJI_0309.JPG', 'DJI_0310.JPG', 'DJI_0311.JPG', 'DJI_0312.JPG', 'DJI_0313.JPG', 'DJI_0314.JPG', 'DJI_0315.JPG', 'DJI_0316.JPG', 'DJI_0317.JPG', 'DJI_0318.JPG', 'DJI_0319.JPG', 'DJI_0320.JPG', 'DJI_0321.JPG', 'DJI_0322.JPG', 'DJI_0323.JPG', 'DJI_0324.JPG', 'DJI_0325.JPG', 'DJI_0326.JPG', 'DJI_0327.JPG', 'DJI_0328.JPG', 'DJI_0329.JPG', 'DJI_0330.JPG', 'DJI_0331.JPG', 'DJI_0332.JPG', 'DJI_0333.JPG', 'DJI_0334.JPG', 'DJI_0335.JPG', 'DJI_0336.JPG', 'DJI_0337.JPG', 'DJI_0338.JPG', 'DJI_0339.JPG', 'DJI_0340.JPG', 'DJI_0341.JPG', 'DJI_0342.JPG', 'DJI_0343.JPG', 'DJI_0344.JPG', 'DJI_0345.JPG', 'DJI_0346.JPG', 'DJI_0347.JPG', 'DJI_0348.JPG', 'DJI_0349.JPG', 'DJI_0350.JPG', 'DJI_0351.JPG', 'DJI_0352.JPG', 'DJI_0353.JPG', 'DJI_0354.JPG', 'DJI_0355.JPG', 'DJI_0356.JPG', 'DJI_0357.JPG', 'DJI_0358.JPG', 'DJI_0359.JPG', 'DJI_0360.JPG', 'DJI_0361.JPG', 'DJI_0362.JPG', 'DJI_0363.JPG', 'DJI_0364.JPG', 'DJI_0365.JPG', 'DJI_0366.JPG', 'DJI_0367.JPG', 'DJI_0368.JPG', 'DJI_0369.JPG', 'DJI_0370.JPG', 'DJI_0371.JPG', 'DJI_0372.JPG', 'DJI_0373.JPG', 'DJI_0374.JPG', 'DJI_0375.JPG', 'DJI_0376.JPG', 'DJI_0377.JPG', 'DJI_0378.JPG', 'DJI_0379.JPG', 'DJI_0380.JPG', 'DJI_0381.JPG', 'DJI_0382.JPG', 'DJI_0383.JPG', 'DJI_0384.JPG', 'DJI_0385.JPG', 'DJI_0386.JPG', 'DJI_0387.JPG', 'DJI_0388.JPG', 'DJI_0389.JPG', 'DJI_0390.JPG', 'DJI_0391.JPG', 'DJI_0392.JPG', 'DJI_0393.JPG', 'DJI_0394.JPG', 'DJI_0395.JPG', 'DJI_0396.JPG', 'DJI_0397.JPG', 'DJI_0398.JPG', 'DJI_0399.JPG', 'DJI_0400.JPG', 'DJI_0401.JPG', 'DJI_0402.JPG', 'DJI_0403.JPG', 'DJI_0404.JPG', 'DJI_0405.JPG', 'DJI_0406.JPG', 'DJI_0407.JPG', 'DJI_0408.JPG', 'DJI_0409.JPG', 'DJI_0410.JPG', 'DJI_0411.JPG', 'DJI_0412.JPG', 'DJI_0413.JPG', 'DJI_0414.JPG', 'DJI_0415.JPG', 'DJI_0416.JPG', 'DJI_0417.JPG', 'DJI_0418.JPG', 'DJI_0419.JPG', 'DJI_0420.JPG', 'DJI_0421.JPG'] in given raw_img_folder[{raw_img_folder}]
    warnings.warn(

tests/test_reconstruct.py::test_class_sensor_in_img_boundary
  /Users/benweinstein/Documents/EasyIDP/./easyidp/reconstruct.py:231: FutureWarning: This API `ignore` (str) will be enhanced and changed to `ignore_overflow` (bool) in the future.
    warnings.warn(

tests/test_reconstruct.py::test_class_sensor_in_img_boundary
  /Users/benweinstein/Documents/EasyIDP/./easyidp/reconstruct.py:246: FutureWarning: This API `ignore` (str) will be enhanced and changed to `ignore_overflow` (bool) in the future.
    warnings.warn(

tests/test_roi.py::test_class_roi_change_crs
tests/test_roi.py::test_class_roi_get_z_from_dsm_errors
tests/test_shp.py::test_read_shp_without_target
tests/test_shp.py::test_read_shp_proj_success_print
tests/test_shp.py::test_read_shp_key_names
tests/test_shp.py::test_convert_shp
  /Users/benweinstein/Documents/EasyIDP/./easyidp/shp.py:399: UserWarning: Not specifying parameter 'name_field', will using the row id (from 0 to end) as the index for each polygon.Please using idp.shp.show_shp_field(shp_path) to display the full available indexs
    warnings.warn(

tests/test_roi.py::test_class_roi_crop
  /Users/benweinstein/Documents/EasyIDP/./easyidp/pointcloud.py:828: UserWarning: Cropped 0 point in given polygon. Please check whether the coords is correct.
    warnings.warn("Cropped 0 point in given polygon. Please check whether the coords is correct.")

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================================================================================================================== short test summary info ===================================================================================================================
FAILED tests/test_metashape.py::test_class_init_metashape_multi_folder - FileNotFoundError: Could not find Metashape project file [/Users/benweinstein/Library/Application Support/easyidp.data/data_for_tests/metashape/nestedfolders.psx]
=================================================================================================== 1 failed, 135 passed, 26 warnings in 303.34s (0:05:03) ===================================================================================================
HowcanoeWang commented 1 year ago

Sorry for my mistake, I have just uploaded the latest version on Google Drive, please reload and try again.

bw4sz commented 1 year ago

Added next commit. Confirmed that new data passes pytest.

==================================================================================================================== test session starts =====================================================================================================================
platform darwin -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/benweinstein/Documents/EasyIDP
collected 136 items

tests/test_cvtools.py ........                                                                                                                                                                                                                         [  5%]
tests/test_data.py ...                                                                                                                                                                                                                                 [  8%]
tests/test_geotiff.py .....................                                                                                                                                                                                                            [ 23%]
tests/test_init_class_func.py .....                                                                                                                                                                                                                    [ 27%]
tests/test_jsonfile.py ..                                                                                                                                                                                                                              [ 28%]
tests/test_metashape.py ..................                                                                                                                                                                                                             [ 41%]
tests/test_pix4d.py ..............                                                                                                                                                                                                                     [ 52%]
tests/test_pointcloud.py ........................                                                                                                                                                                                                      [ 69%]
tests/test_reconstruct.py ........                                                                                                                                                                                                                     [ 75%]
tests/test_roi.py .................                                                                                                                                                                                                                    [ 88%]
tests/test_shp.py ............