Skip to content

Commit afa7ee7

Browse files
committed
improve scene mode
1 parent 1a96a11 commit afa7ee7

41 files changed

Lines changed: 4175 additions & 869 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ jobs:
7070
libxkbcommon-dev \
7171
libinput-dev \
7272
libudev-dev \
73-
libseat-dev
73+
libseat-dev \
74+
libclang-dev \
75+
libusb-1.0-0-dev
7476
7577
- name: Install just
7678
uses: extractions/setup-just@v3
@@ -147,7 +149,9 @@ jobs:
147149
libxkbcommon-dev \
148150
libinput-dev \
149151
libudev-dev \
150-
libseat-dev
152+
libseat-dev \
153+
libclang-dev \
154+
libusb-1.0-0-dev
151155
152156
- name: Install cross
153157
if: ${{ matrix.use_cross }}
@@ -161,7 +165,7 @@ jobs:
161165
if [ "${{ matrix.use_cross }}" = "true" ]; then
162166
cross build --target ${{ matrix.target }}
163167
else
164-
just build-debug --target ${{ matrix.target }}
168+
cargo build --target ${{ matrix.target }}
165169
fi
166170
167171
flatpak-x86_64:

Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ description = "Camera application for the COSMIC™ desktop"
77
repository = "https://github.com/cosmic-utils/camera"
88
authors = ["Frederic Laing <frederic.laing.development@gmail.com>"]
99

10+
[features]
11+
default = ["freedepth"]
12+
# freedepth userspace library for Kinect depth cameras (fallback when kernel driver unavailable)
13+
# Only works on x86_64 due to libclang/bindgen requirements
14+
freedepth = ["dep:freedepth"]
15+
1016
[dependencies]
1117
futures = "0.3.31"
1218
i18n-embed = { version = "0.16.0", features = [
@@ -41,9 +47,13 @@ libc = "0.2.178"
4147
dng = "1.5"
4248
async-stream = "0.3"
4349
v4l = "0.14"
44-
freedepth = { git = "https://github.com/FreddyFunk/freedepth", rev = "aab2bbcc9c1c196751d8eb37a9b704e9b75683cb" } # Multi-device depth camera library
4550
las = { version = "0.9", features = ["laz"] } # LAZ point cloud export
4651

52+
# freedepth is only available on x86_64 (requires libclang for v4l2-sys-mit bindgen)
53+
# Enabled via the "freedepth" feature flag (on by default)
54+
[target.'cfg(target_arch = "x86_64")'.dependencies]
55+
freedepth = { git = "https://github.com/FreddyFunk/freedepth", rev = "aab2bbcc9c1c196751d8eb37a9b704e9b75683cb", optional = true } # Multi-device depth camera library
56+
4757
# Separate wgpu for compute pipelines (independent from libcosmic's wgpu for UI)
4858
# This allows us to use the latest wgpu features like open_with_callback for low-priority queues
4959
[dependencies.wgpu-compute]

src/app/handlers/camera.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,26 @@ impl AppModel {
585585
// Get scene view mode (point cloud vs mesh)
586586
let scene_view_mode = self.preview_3d.view_mode;
587587

588+
// Get filter mode for scene rendering
589+
use crate::app::state::FilterType;
590+
let filter_mode = match self.selected_filter {
591+
FilterType::Standard => 0u32,
592+
FilterType::Mono => 1,
593+
FilterType::Sepia => 2,
594+
FilterType::Noir => 3,
595+
FilterType::Vivid => 4,
596+
FilterType::Cool => 5,
597+
FilterType::Warm => 6,
598+
FilterType::Fade => 7,
599+
FilterType::Duotone => 8,
600+
FilterType::Vignette => 9,
601+
FilterType::Negative => 10,
602+
FilterType::Posterize => 11,
603+
FilterType::Solarize => 12,
604+
FilterType::ChromaticAberration => 13,
605+
FilterType::Pencil => 14,
606+
};
607+
588608
info!(
589609
depth_format = ?depth_format,
590610
mirror,
@@ -594,6 +614,7 @@ impl AppModel {
594614
?sensor_type,
595615
showing_depth_colormap,
596616
?scene_view_mode,
617+
filter_mode,
597618
"Rendering 3D scene"
598619
);
599620

@@ -616,6 +637,7 @@ impl AppModel {
616637
depth_format,
617638
mirror,
618639
apply_rgb_registration,
640+
filter_mode,
619641
)
620642
.await
621643
.map(|r| (r.width, r.height, r.rgba)),
@@ -638,6 +660,7 @@ impl AppModel {
638660
mirror,
639661
apply_rgb_registration,
640662
DEPTH_DISCONTINUITY_THRESHOLD,
663+
filter_mode,
641664
)
642665
.await
643666
.map(|r| (r.width, r.height, r.rgba))

src/app/handlers/capture.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ impl AppModel {
668668
registration_table: shader_reg.registration_table,
669669
depth_to_rgb_shift: shader_reg.depth_to_rgb_shift,
670670
target_offset: shader_reg.target_offset,
671-
reg_x_val_scale: 256, // Standard Kinect scale factor
672671
reg_scale_x,
673672
reg_scale_y,
674673
reg_y_offset,

src/app/handlers/depth_camera.rs

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,32 @@
55
//! Handles depth camera device control including motor tilt, native streaming,
66
//! 3D preview frame polling, depth visualization settings, and calibration dialogs.
77
//! LED is automatically managed by freedepth based on device state.
8+
//!
9+
//! When freedepth is not available (non-x86_64 or feature disabled), stub
10+
//! implementations are provided that return Task::none().
811
9-
use crate::app::state::{AppModel, Message, SceneViewMode};
12+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
1013
use crate::backends::camera::{NativeDepthBackend, depth_device_index, rgb_to_rgba};
11-
use cosmic::Task;
14+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
1215
use freedepth::{DepthRegistration, TILT_MAX_DEGREES, TILT_MIN_DEGREES};
16+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
1317
use std::time::{Duration, Instant};
18+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
1419
use tracing::{debug, info, warn};
1520

21+
use crate::app::state::{AppModel, Message};
22+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
23+
use crate::app::state::SceneViewMode;
24+
use cosmic::Task;
25+
1626
/// Set up GPU shader registration data from device calibration
1727
///
1828
/// This spawns an async task to update the point cloud and mesh processors
1929
/// with the device-specific registration tables. Call this after the native
2030
/// depth backend is initialized.
2131
///
2232
/// Uses the generic DepthRegistration trait for device-agnostic access.
33+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
2334
pub fn setup_shader_registration_data(registration: &dyn DepthRegistration) {
2435
let reg_data = crate::shaders::RegistrationData {
2536
registration_table: registration.registration_table_flat().to_vec(),
@@ -41,6 +52,8 @@ pub fn setup_shader_registration_data(registration: &dyn DepthRegistration) {
4152
});
4253
}
4354

55+
// Full implementation when freedepth is available
56+
#[cfg(all(target_arch = "x86_64", feature = "freedepth"))]
4457
impl AppModel {
4558
/// Handle setting depth camera tilt angle (desired state)
4659
///
@@ -58,7 +71,7 @@ impl AppModel {
5871
self.kinect.tilt_angle = degrees;
5972

6073
// Send command to motor via global motor control
61-
use crate::backends::camera::depth_controller::set_motor_tilt;
74+
use crate::backends::camera::motor_control::set_motor_tilt;
6275
if let Err(e) = set_motor_tilt(degrees) {
6376
tracing::warn!("Failed to set depth camera tilt: {}", e);
6477
}
@@ -150,7 +163,6 @@ impl AppModel {
150163
registration_table: registration.registration_table_flat().to_vec(),
151164
depth_to_rgb_shift: registration.depth_to_rgb_shift_table().to_vec(),
152165
target_offset: registration.target_offset(),
153-
reg_x_val_scale: 256,
154166
reg_scale_x: 1.0,
155167
reg_scale_y: 1.0,
156168
reg_y_offset: 0,
@@ -207,7 +219,7 @@ impl AppModel {
207219
video_frame_is_new =
208220
self.preview_3d.last_render_video_timestamp != Some(video_frame.timestamp);
209221

210-
let rgba_data = rgb_to_rgba(&video_frame.rgb_data);
222+
let rgba_data = rgb_to_rgba(&video_frame.data);
211223

212224
use crate::backends::camera::types::{CameraFrame, PixelFormat};
213225
let frame = CameraFrame {
@@ -470,3 +482,88 @@ impl AppModel {
470482
self.handle_request_point_cloud_render()
471483
}
472484
}
485+
486+
// Stub implementations when freedepth is disabled
487+
#[cfg(not(all(target_arch = "x86_64", feature = "freedepth")))]
488+
impl AppModel {
489+
pub(crate) fn handle_set_kinect_tilt(&mut self, _degrees: i8) -> Task<cosmic::Action<Message>> {
490+
Task::none()
491+
}
492+
493+
pub(crate) fn update_kinect_state(&mut self) -> Task<cosmic::Action<Message>> {
494+
self.kinect.is_device = false;
495+
Task::none()
496+
}
497+
498+
pub(crate) fn is_current_camera_depth_sensor(&self) -> bool {
499+
false
500+
}
501+
502+
pub(crate) fn handle_start_native_kinect_streaming(&mut self) -> Task<cosmic::Action<Message>> {
503+
Task::none()
504+
}
505+
506+
pub(crate) fn handle_stop_native_kinect_streaming(&mut self) -> Task<cosmic::Action<Message>> {
507+
Task::none()
508+
}
509+
510+
pub(crate) fn handle_poll_native_kinect_frames(&mut self) -> Task<cosmic::Action<Message>> {
511+
Task::none()
512+
}
513+
514+
pub(crate) fn handle_toggle_depth_overlay(&mut self) -> Task<cosmic::Action<Message>> {
515+
Task::none()
516+
}
517+
518+
pub(crate) fn handle_toggle_depth_grayscale(&mut self) -> Task<cosmic::Action<Message>> {
519+
Task::none()
520+
}
521+
522+
pub(crate) fn handle_show_calibration_dialog(&mut self) -> Task<cosmic::Action<Message>> {
523+
Task::none()
524+
}
525+
526+
pub(crate) fn handle_close_calibration_dialog(&mut self) -> Task<cosmic::Action<Message>> {
527+
Task::none()
528+
}
529+
530+
pub(crate) fn handle_start_calibration(&mut self) -> Task<cosmic::Action<Message>> {
531+
Task::none()
532+
}
533+
534+
pub(crate) fn handle_toggle_3d_preview(&mut self) -> Task<cosmic::Action<Message>> {
535+
Task::none()
536+
}
537+
538+
pub(crate) fn handle_toggle_scene_view_mode(&mut self) -> Task<cosmic::Action<Message>> {
539+
Task::none()
540+
}
541+
542+
pub(crate) fn handle_preview_3d_mouse_pressed(
543+
&mut self,
544+
_x: f32,
545+
_y: f32,
546+
) -> Task<cosmic::Action<Message>> {
547+
Task::none()
548+
}
549+
550+
pub(crate) fn handle_preview_3d_mouse_moved(
551+
&mut self,
552+
_x: f32,
553+
_y: f32,
554+
) -> Task<cosmic::Action<Message>> {
555+
Task::none()
556+
}
557+
558+
pub(crate) fn handle_preview_3d_mouse_released(&mut self) -> Task<cosmic::Action<Message>> {
559+
Task::none()
560+
}
561+
562+
pub(crate) fn handle_reset_3d_preview_rotation(&mut self) -> Task<cosmic::Action<Message>> {
563+
Task::none()
564+
}
565+
566+
pub(crate) fn handle_zoom_3d_preview(&mut self, _delta: f32) -> Task<cosmic::Action<Message>> {
567+
Task::none()
568+
}
569+
}

0 commit comments

Comments
 (0)