Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the raw_image_folder docs description about the metashape default image path #95

Open
bw4sz opened this issue Apr 5, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@bw4sz
Copy link
Contributor

bw4sz commented Apr 5, 2023

I am working on a jupyter notebook that hopefully can serve to help others understand the workflow and provide some wording familiar to drone users for environmental surveys. I'll be making small issues, mostly related to docs that could help the next users access this great tool.

  1. How does rio.back2raw() determine the location of the raw images when specifying the save folder?
import easyidp as idp
import numpy as np
from deepforest import main
from deepforest import utilities
import glob
from matplotlib import pyplot

# Load a deepforest bird prediction module
m = main.deepforest()
m.use_bird_release()

# 1) Predict birds in orthomosaic for existing model
predictions = m.predict_tile("/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/Vacation_03_20_2023.tif", patch_size=2000, patch_overlap=0)

# 2) Export predictions to a shapefile
gdf = utilities.boxes_to_shapefile(df=predictions, root_dir="/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/")
gdf.to_file("/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/Vacation_03_20_2023_ortho_predictions.shp")

# 3) Read in Agisoft Project
ms = idp.Metashape("/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/Vacation/Vacation_03_20_2023.psx", chunk_id=0)

# 4 ) Read in shapefile as a 'region of interest', each bird will be a seperate ROI
roi = idp.ROI("/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/Vacation_03_20_2023_ortho_predictions.shp", name_field=None)

# 5) Get Digital Elevation Model exported from agisoft
dom = roi.get_z_from_dsm("/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/Vacation_03_20_2023_DEM.tif")

# 6) Backward Project to find each region of interest in raw imagery
img_dict = roi.back2raw(ms)

# Or save drawings of found images
img_dict = roi.back2raw(ms, save_folder="/Users/benweinstein/Dropbox/Weecology/everglades_species/Raw_versus_Ortho/results/")
builtins.FileNotFoundError: No such file: '/Users/benweinstein/Dropbox/Weecology/everglades_species/InspireRawData/Vacation/Vacation_03_20_2023/DJI_0093.JPG'

Which is fine, i can easily go and put the images there, but how was the location determined? Moving the photos to that location works great. Not obvious from the doc string. https://easyidp.readthedocs.io/en/latest/python_api/manualdoc/easyidp.roi.ROI.html#easyidp.roi.ROI.back2raw

57_DJI_0119_at_top_583_left_1036

@HowcanoeWang HowcanoeWang self-assigned this Apr 6, 2023
@HowcanoeWang HowcanoeWang added the documentation Improvements or additions to documentation label Apr 6, 2023
@HowcanoeWang
Copy link
Member

HowcanoeWang commented Apr 6, 2023

This is a problem happens at reading the raw image but could not find it using the metashape project recorded image path.

In the metashape project files, project.files/0/0/frames.zip/docs.xml

There is a path to parse the relative path between the raw image and metashape project. Take the previous ForestBirds() dataset as example:

<camera camera_id="17">
      <photo path="../../../../../Inspire Raw Data/Hidden_Little/Hidden_Little_03_24_2022/DJI_0126.JPG">
        <meta>
          <property name="DJI/AbsoluteAltitude" value="+42.43"/>
          <property name="DJI/FlightPitchDegree" value="-4.50"/>
          <property name="DJI/FlightRollDegree" value="+2.70"/>

So, did you change the path of raw image folder after finishing the reconstruction?

(PS: I also need to modify the ForestBirds dataset due to the same reason)

@bw4sz
Copy link
Contributor Author

bw4sz commented Apr 6, 2023

Got it. The original workflow had no intention of backwards projection, we didn't keep the projects together with the raw imagery. We are changing this now.

@bw4sz bw4sz closed this as completed Apr 6, 2023
@HowcanoeWang HowcanoeWang changed the title How to determine the location of raw images in rio.back2raw(). update the raw_image_folder docs description about the metashape default image path Apr 7, 2023
@HowcanoeWang HowcanoeWang reopened this Apr 7, 2023
@HowcanoeWang
Copy link
Member

Provide a folder changing function:

# how to change the demo detaset
ms = idp.Metashape(
    fb.metashape.project, chunk_id=0,
    raw_img_folder=fb.data_dir / "Hidden_Little_03_24_2022")

# the string like 'c:/path/to/new/folder/' should also work

Apologies no time for detailed documentation currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Done
Development

No branches or pull requests

2 participants