Skip to content

Commit

Permalink
#54 Exact capture time recorded for each inference
Browse files Browse the repository at this point in the history
  • Loading branch information
rland93 committed May 26, 2022
1 parent 9e9360f commit 5ed9350
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions odcl_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def get_next_in_dir(datadir: Path, suffix: str, k=5):
# odcl data dir is set to a rospy param
data_dir = rospy.get_param("/odcl/odcldir", "~/odcldata")
# make a folder with today's date
data_dir = Path(data_dir).resolve() / datetime.date.today().strftime("%Y%m%d")
todaysdate = datetime.date.today().strftime("%Y%m%d")
data_dir = Path(data_dir).resolve() / todaysdate
# make a directory to save raw images
raw_image_dir = data_dir / "raw"
# make a directory to save cropped images
Expand All @@ -120,7 +121,7 @@ def get_next_in_dir(datadir: Path, suffix: str, k=5):
odcl_data_file = data_dir / str(run_id_str + "-data.csv")

# write CSV headers to file
headers = "run_id,frame_no,target_no,target_id,img_path,crop_path,score,class,shape_color,letter_color,latitude,longitude,inference_time\n"
headers = "run_id,frame_no,target_no,target_id,img_path,crop_path,score,class,shape_color,letter_color,latitude,longitude,inference_time,captime\n"
with open(odcl_data_file, "a") as f:
f.write(headers)

Expand All @@ -138,6 +139,7 @@ def get_next_in_dir(datadir: Path, suffix: str, k=5):
if capture.isOpened():
# read raw image from camera
status, image_raw = capture.read()
captime = datetime.datetime.now().strftime("%Y%m%d %H%M%S%f%p")

# get frame number
frameno_str = str(frameno).rjust(5)
Expand All @@ -164,7 +166,7 @@ def get_next_in_dir(datadir: Path, suffix: str, k=5):
rospy.loginfo(f"\tFound {len(targets)} targets.")

for i, target in enumerate(targets):
targetno = str(i).rjust(2)
targetno = str(i).ljust(2)
# unpack target information
lat = target["lat"]
lon = target["lon"]
Expand All @@ -189,7 +191,7 @@ def get_next_in_dir(datadir: Path, suffix: str, k=5):
targetcsvline = f"{run_id},{frameno},{targetno},{targetid},"
targetcsvline += f"{raw_img_path},{crop_fname},"
targetcsvline += f"{score},{shape},{scolor},{lcolor},{lat},{lon},"
targetcsvline += f"{inftime}\n"
targetcsvline += f"{inftime},{captime}\n"
with open(odcl_data_file, "a") as f:
f.write(targetcsvline)

Expand Down

0 comments on commit 5ed9350

Please sign in to comment.