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

feat(camera-app): Snapshot will get saved in the ~/Pictures directory. #178

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ members = [
default-members = ["settings-app", "camera", "files"]

[workspace.package]
version = "0.1.15"
version = "0.1.16"
authors = [
"Sweta <[email protected]>",
"Naman <namana-mecha@mechasystems.com>",
"Naman <[email protected]>",
"Minesh <[email protected]>",
]
edition = "2021"
Expand Down Expand Up @@ -38,4 +38,4 @@ tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"]}
anyhow = { version = "1.0.75", features = ["backtrace"]}
tokio = { version = "1.33", features = ["full"] }
networkmanager = { path = "../commons/networkmanager"}
networkmanager = { path = "../commons/networkmanager"}
1 change: 1 addition & 0 deletions apps/camera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ serde = "1.0.217"
serde_yaml = "0.9.34"
dirs = "5.0.1"
const_format = "0.2.34"
chrono = "0.4.39"

[package.metadata.deb]
name = "mechanix-camera"
Expand Down
21 changes: 17 additions & 4 deletions apps/camera/src/contexts/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ impl Camera {
}

pub fn save_frame() {
let frame = Self::get().frame_buffer.get();
frame.save("frame.jpg").unwrap();

RUNTIME.spawn(async {
GST_CAMERA
.lock()
Expand Down Expand Up @@ -173,7 +170,23 @@ impl Camera {
let buffer = yuyv422_to_rgb(frame.as_raw(), true).unwrap();
let frame: ImageBuffer<image::Rgba<u8>, Vec<u8>> =
ImageBuffer::from_raw(width, height, buffer).unwrap();
frame.save("frame2.jpg").unwrap();

let now = chrono::Local::now();
let formatted_time = now.format("%Y%m%d_%H%M%S").to_string();
let mut pictures_dir = std::path::PathBuf::from(
std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
);
pictures_dir.push("Pictures");

if !pictures_dir.exists() {
std::fs::create_dir_all(&pictures_dir)
.expect("Couldn't create directory `Pictures`");
}

let filename = format!("Snapshot_{}.jpg", formatted_time);
let filepath = pictures_dir.join(&filename);
frame.save(filepath).unwrap();

break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl Component for SettingsScreen {
);

list_items = list_items.push(network_div);
list_items = list_items.push(bluetooth_div);
// list_items = list_items.push(bluetooth_div);
list_items = list_items.push(display_div);
// list_items = list_items.push(appearance_div);
list_items = list_items.push(battery_div);
Expand Down