-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kornia/rtspcam-stream
Rtspcam stream and remote rerun logger
- Loading branch information
Showing
19 changed files
with
710 additions
and
326 deletions.
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
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,5 @@ | ||
[build] | ||
default-target = "aarch64-unknown-linux-gnu" | ||
|
||
[target.aarch64-unknown-linux-gnu] | ||
dockerfile = "docker/aarch64.Dockerfile" |
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,44 @@ | ||
( | ||
tasks: [ | ||
( | ||
id: "cam0", | ||
type: "crate::cu29::tasks::V4L2Camera", | ||
config: { | ||
"camera_id": 0, | ||
"rows": 480, | ||
"cols": 640, | ||
"fps": 30, | ||
} | ||
), | ||
// NOTE: uncomment to use this camera | ||
// ( | ||
// id: "cam0", | ||
// type: "crate::cu29::tasks::RTSPCamera", | ||
// config: { | ||
// // URL of the RTSP camera | ||
// // rtsp://<username>:<password>@<ip>:<port>/<stream> | ||
// "url": "rtsp://tapo_entrance:[email protected]:554/stream2", | ||
// } | ||
// ), | ||
( | ||
id: "rerun", | ||
type: "crate::cu29::tasks::RerunLogger", | ||
config: { | ||
// Path to the directory where the logs will be stored | ||
"path": "/tmp/", | ||
// IP address of the rerun server | ||
"ip": "192.168.1.144", | ||
// Port of the rerun server | ||
"port": 9876, | ||
} | ||
) | ||
], | ||
cnx: [ | ||
(src: "cam0", dst: "rerun", msg: "crate::cu29::msgs::ImageRGBU8Msg"), | ||
] | ||
, | ||
logging: ( | ||
slab_size_mib: 1024, // Preallocates 1GiB of memory map file at a time | ||
section_size_mib: 100, // Preallocates 100MiB of memory map per section for the main logger. | ||
), | ||
) |
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 @@ | ||
#FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge-centos | ||
#FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 | ||
#FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu@sha256:b4eff900bf2007cbcb54335a5826dedde6082f484bc8be7499d5ed071608ecf3 | ||
FROM nvcr.io/nvidia/l4t-base:r35.2.1 | ||
|
||
RUN apt-get update && apt-get install --assume-yes \ | ||
cmake \ | ||
curl \ | ||
pkg-config \ | ||
&& \ | ||
apt-get clean | ||
|
||
RUN dpkg --add-architecture arm64 | ||
|
||
RUN apt-get update && apt-get install --assume-yes \ | ||
nasm \ | ||
libgstreamer1.0-dev:arm64 \ | ||
libgstreamer-plugins-base1.0-dev:arm64 \ | ||
libssl-dev:arm64 \ | ||
libglib2.0-dev:arm64 \ | ||
libudev-dev:arm64 \ | ||
&& \ | ||
apt-get clean | ||
|
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,62 @@ | ||
#!/bin/bash | ||
|
||
# Stop the script if any command fails | ||
set -e | ||
|
||
# Parse command line arguments | ||
while getopts "r:u:" opt; do | ||
case $opt in | ||
r) TARGET_IP="$OPTARG" # Target IP | ||
;; | ||
u) TARGET_USER="$OPTARG" # Target user | ||
;; | ||
esac | ||
done | ||
|
||
# Check if required arguments are provided | ||
if [ -z "$TARGET_IP" ] || [ -z "$TARGET_USER" ]; then | ||
echo "Usage: $0 -r <target-ip> -u <target-user>" | ||
exit 1 | ||
fi | ||
|
||
# Configuration | ||
TARGET_PATH="/home/$TARGET_USER/deploy" | ||
BINARY_NAME="serve" | ||
LOCAL_FOLDER="/tmp/deploy_serve" | ||
DEPLOY_ARCH="aarch64-unknown-linux-gnu" | ||
|
||
# Colors for output | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# Function to print status | ||
print_status() { | ||
echo -e "${GREEN}==> ${1}${NC}" | ||
} | ||
|
||
print_error() { | ||
echo -e "${RED}==> ERROR: ${1}${NC}" | ||
exit 1 | ||
} | ||
|
||
# Check if cross is installed | ||
if ! command -v cross &> /dev/null; then | ||
print_error "cross is not installed. Install it with: cargo install cross" | ||
fi | ||
|
||
# Build the release binary | ||
print_status "Building release binary for aarch64..." | ||
cross build --target $DEPLOY_ARCH --release --bin $BINARY_NAME || print_error "Build failed" | ||
rsync -a target/$DEPLOY_ARCH/release/$BINARY_NAME $LOCAL_FOLDER | ||
|
||
# Check if binary exists | ||
if [ ! -f "target/$DEPLOY_ARCH/release/$BINARY_NAME" ]; then | ||
print_error "Binary not found after build" | ||
fi | ||
|
||
# Copy to remote machine | ||
print_status "Copying to $TARGET_USER@$TARGET_IP:$TARGET_PATH..." | ||
rsync -a $LOCAL_FOLDER $TARGET_USER@$TARGET_IP:$TARGET_PATH | ||
|
||
print_status "Deploy completed successfully!" |
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
This file was deleted.
Oops, something went wrong.
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,86 @@ | ||
use cu29::prelude::*; | ||
use cu29_helpers::basic_copper_setup; | ||
use std::sync::{atomic::AtomicBool, Arc}; | ||
const SLAB_SIZE: Option<usize> = Some(150 * 1024 * 1024); | ||
|
||
pub type PipelineResult = Result<(), Box<dyn std::error::Error + Send + Sync>>; | ||
|
||
// NOTE: this will use the default config file in the current directory during compilation | ||
// however, it will be overridden by the ron config string when the pipeline is started | ||
#[copper_runtime(config = "bubbaloop.ron")] | ||
struct CopperApp {} | ||
|
||
pub struct CopperPipeline(pub CopperApp); | ||
|
||
impl CopperPipeline { | ||
pub fn new() -> CuResult<Self> { | ||
// NOTE: this is a temporary solution to store the logger in the user's home directory | ||
let logger_dir = std::path::PathBuf::from(&format!("/home/{}", whoami::username())); | ||
let logger_path = logger_dir.join("bubbaloop.copper"); | ||
debug!("Logger path: {}", path = &logger_path); | ||
|
||
let copper_ctx = basic_copper_setup(&logger_path, SLAB_SIZE, true, None)?; | ||
let application = CopperAppBuilder::new().with_context(&copper_ctx).build()?; | ||
|
||
Ok(Self(application)) | ||
} | ||
} | ||
|
||
/// Spawns a new thread for the pipeline | ||
/// | ||
/// This function is used to spawn a new thread for the pipeline | ||
/// and to pass the stop signal to the pipeline | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `pipeline_id` - The id of the pipeline | ||
/// * `stop_signal` - The stop signal to stop the pipeline | ||
/// | ||
/// # Returns | ||
/// | ||
/// A handle to the thread that runs the pipeline | ||
pub fn spawn_cu29_thread( | ||
pipeline_id: &str, | ||
stop_signal: Arc<AtomicBool>, | ||
) -> std::thread::JoinHandle<PipelineResult> { | ||
let pipeline_id = pipeline_id.to_string(); | ||
std::thread::spawn({ | ||
let stop_signal = stop_signal.clone(); | ||
move || -> PipelineResult { | ||
// parse the ron config string and create the pipeline | ||
let mut app = CopperPipeline::new()?; | ||
|
||
// create the pipeline and start the tasks | ||
app.start_all_tasks()?; | ||
|
||
while !stop_signal.load(std::sync::atomic::Ordering::Relaxed) { | ||
// we run the pipeline iteration step by step | ||
app.run_one_iteration()?; | ||
|
||
// NOTE: is this really needed? | ||
std::thread::sleep(std::time::Duration::from_millis(30)); | ||
} | ||
|
||
// stop the pipeline and wait for the tasks to finish | ||
app.stop_all_tasks()?; | ||
|
||
log::debug!("Pipeline {} stopped", pipeline_id); | ||
|
||
Ok(()) | ||
} | ||
}) | ||
} | ||
|
||
impl std::ops::Deref for CopperPipeline { | ||
type Target = CopperApp; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl std::ops::DerefMut for CopperPipeline { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} |
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,3 @@ | ||
pub mod app; | ||
pub mod msgs; | ||
pub mod tasks; |
Oops, something went wrong.