-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add objectron app that logs objectron dataset
- Loading branch information
Showing
17 changed files
with
2,348 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
**/target | ||
/.vscode | ||
/media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dataset/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "objectron" | ||
version = "0.1.0" | ||
edition = "2021" | ||
rust-version = "1.60" | ||
license = "MIT OR Apache-2.0" | ||
publish = false | ||
|
||
|
||
[dependencies] | ||
log_types = { path = "../log_types" } | ||
viewer = { path = "../viewer" } | ||
|
||
anyhow = "1" | ||
clap = "3.1" | ||
glam = "0.20" # to convert rotation matrices to quaternions | ||
image = { version = "0.23", default-features = false, features = ["jpeg"] } | ||
itertools = "0.10" | ||
prost = "0.10" | ||
tracing = "0.1" | ||
tracing-subscriber = "0.3" | ||
|
||
[build-dependencies] | ||
prost-build = "0.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```sh | ||
./download_dataset.py | ||
cargo run --release -p objectron -- objectron/dataset/camera/batch-5/31 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fn main() -> std::io::Result<()> { | ||
// for filename in [ | ||
// // "a_r_capture_metadata.proto", | ||
// "annotation_data.proto", | ||
// // "object.proto", | ||
// ] { | ||
// println!("cargo:rerun-if-changed=src/protos/{filename}"); | ||
// prost_build::Config::new() | ||
// .out_dir("src/generated/") | ||
// .compile_protos(&[&format!("src/protos/{filename}")], &["src/protos/"])?; | ||
// } | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# TODO: translate to build.rs instead? | ||
|
||
import requests | ||
import os | ||
|
||
|
||
def download(url, path): | ||
if not os.path.exists(path): | ||
print(f"downloading {url}…") | ||
response = requests.get(url) | ||
with open(path, "wb") as file: | ||
file.write(response.content) | ||
|
||
|
||
def split_video_into_frames(video_path, frames_path): | ||
if not os.path.exists(frames_path): | ||
print("Splitting video into frames…") | ||
os.makedirs(frames_path, exist_ok=True) | ||
|
||
import cv2 | ||
vidcap = cv2.VideoCapture(video_path) | ||
success, image = vidcap.read() | ||
count = 0 | ||
while success: | ||
cv2.imwrite(f"{frames_path}/{count}.jpg", image) | ||
success, image = vidcap.read() | ||
count += 1 | ||
|
||
|
||
public_url = "https://storage.googleapis.com/objectron" | ||
|
||
|
||
def download_data(video_id): | ||
print(f"downloading {video_id}…") | ||
|
||
dir = f"dataset/{video_id}" | ||
os.makedirs(dir, exist_ok=True) | ||
|
||
download(f"{public_url}/videos/{video_id}/video.MOV", | ||
f"{dir}/video.MOV") | ||
|
||
# use object.proto | ||
download(f"{public_url}/videos/{video_id}/geometry.pbdata", | ||
f"{dir}/geometry.pbdata") | ||
|
||
# Please refer to Parse Annotation tutorial to see how to parse the annotation files. | ||
download(f"{public_url}/annotations/{video_id}.pbdata", | ||
f"{dir}/annotation.pbdata") | ||
|
||
split_video_into_frames(f"{dir}/video.MOV", f"{dir}/video") | ||
|
||
|
||
def download_dataset(name): | ||
video_ids = requests.get( | ||
f"{public_url}/v1/index/{name}_annotations_test").text | ||
video_ids = video_ids.split('\n') | ||
for i in range(10): | ||
download_data(video_ids[i]) | ||
|
||
|
||
download_dataset("bike") | ||
download_dataset("book") | ||
download_dataset("bottle") | ||
download_dataset("camera") | ||
download_dataset("cereal_box") | ||
download_dataset("chair") | ||
download_dataset("cup") | ||
download_dataset("laptop") | ||
download_dataset("shoe") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
brew install protobuf-c |
Oops, something went wrong.