pub struct CameraController {
base_path: String,
fullsize_map_image: RwLock<FullsizeMapImage>,
thumbnail_map_image: RwLock<ThumbnailMapImage>,
request_client: Arc<HTTPClient>,
}Expand description
A struct for managing camera-related operations and map snapshots.
Fields§
§base_path: StringThe base path for saving map image data.
fullsize_map_image: RwLock<FullsizeMapImage>The lock-protected full-size map image.
thumbnail_map_image: RwLock<ThumbnailMapImage>The lock-protected thumbnail map image.
request_client: Arc<HTTPClient>The HTTP client for sending requests.
Implementations§
Source§impl CameraController
impl CameraController
Sourceconst LAST_IMG_END_DELAY: TimeDelta
const LAST_IMG_END_DELAY: TimeDelta
Constant minimum delay to perform another image.
Sourceconst ZO_IMG_FOLDER: &'static str = "zo_img/"
const ZO_IMG_FOLDER: &'static str = "zo_img/"
Directory where zoned objective images should be stored.
Sourceconst ZO_IMG_ACQ_DELAY: TimeDelta
const ZO_IMG_ACQ_DELAY: TimeDelta
Constant TimeDelta between images when in zoned objective acquisition.
Sourcepub fn start(base_path: String, request_client: Arc<HTTPClient>) -> Self
pub fn start(base_path: String, request_client: Arc<HTTPClient>) -> Self
Initializes the CameraController with the given base path and HTTP client.
§Arguments
base_path- The base path for storing files.request_client- The HTTP client for sending requests.
§Returns
A new instance of CameraController.
Sourcefn score_offset(
decoded_image: &RgbImage,
base: &FullsizeMapImage,
offset: Vec2D<u32>,
) -> Vec2D<i32>
fn score_offset( decoded_image: &RgbImage, base: &FullsizeMapImage, offset: Vec2D<u32>, ) -> Vec2D<i32>
Sourcepub async fn get_image(
&self,
f_cont_locked: Arc<RwLock<FlightComputer>>,
angle: CameraAngle,
) -> Result<(Vec2D<I32F32>, Vec2D<i32>, RgbImage), Box<dyn Error + Send + Sync>>
pub async fn get_image( &self, f_cont_locked: Arc<RwLock<FlightComputer>>, angle: CameraAngle, ) -> Result<(Vec2D<I32F32>, Vec2D<i32>, RgbImage), Box<dyn Error + Send + Sync>>
Performs the HTTP request to retrieve an image from the DRS backend. Then calculates the position and image offset.
§Arguments
f_cont_locked: A shared RwLock containing the FlightComputer instance
angle: The current CameraAngle
§Returns
A Result containing a tuple with:
- The
Vec2D<I32F32>position where the image was taken - The
Vec2D<i32>offset in the map image buffer - The decoded
RgbImageor an Error
Sourcepub async fn shoot_image_to_map_buffer(
&self,
f_cont_locked: Arc<RwLock<FlightComputer>>,
angle: CameraAngle,
) -> Result<(Vec2D<I32F32>, Vec2D<u32>), Box<dyn Error + Send + Sync>>
pub async fn shoot_image_to_map_buffer( &self, f_cont_locked: Arc<RwLock<FlightComputer>>, angle: CameraAngle, ) -> Result<(Vec2D<I32F32>, Vec2D<u32>), Box<dyn Error + Send + Sync>>
Sourcepub async fn shoot_image_to_zo_buffer(
&self,
f_cont_locked: Arc<RwLock<FlightComputer>>,
angle: CameraAngle,
zoned_objective_map_image: Option<&mut OffsetZonedObjectiveImage>,
) -> Result<Vec2D<I32F32>, Box<dyn Error + Send + Sync>>
pub async fn shoot_image_to_zo_buffer( &self, f_cont_locked: Arc<RwLock<FlightComputer>>, angle: CameraAngle, zoned_objective_map_image: Option<&mut OffsetZonedObjectiveImage>, ) -> Result<Vec2D<I32F32>, Box<dyn Error + Send + Sync>>
Captures an image, processes it, and stores it in a custom zoned objective buffer.
§Arguments
f_cont_locked- The lock-protected flight computer.angle- The camera angle and field of view.zoned_objective_map_image: An optional mutable reference to anOffsetZonedObjectiveImage
§Returns
The imaging position as Vec2D<I32F32> or an error.
Sourceasync fn update_thumbnail_area_from_fullsize(
&self,
offset: Vec2D<u32>,
size: u32,
)
async fn update_thumbnail_area_from_fullsize( &self, offset: Vec2D<u32>, size: u32, )
Updates the thumbnail area of the map based on the full-size map data.
§Arguments
offset- Offset to update.size- Size of the region to update.
Sourcefn decode_png_data(
collected_png: &[u8],
angle: CameraAngle,
) -> Result<RgbImage, Box<dyn Error + Send + Sync>>
fn decode_png_data( collected_png: &[u8], angle: CameraAngle, ) -> Result<RgbImage, Box<dyn Error + Send + Sync>>
Sourcepub(crate) async fn export_and_upload_objective_png(
&self,
objective_id: usize,
offset: Vec2D<u32>,
size: Vec2D<u32>,
export_path: Option<PathBuf>,
zoned_objective_map_image: Option<&OffsetZonedObjectiveImage>,
) -> Result<(), Box<dyn Error>>
pub(crate) async fn export_and_upload_objective_png( &self, objective_id: usize, offset: Vec2D<u32>, size: Vec2D<u32>, export_path: Option<PathBuf>, zoned_objective_map_image: Option<&OffsetZonedObjectiveImage>, ) -> Result<(), Box<dyn Error>>
Exports a specific region of the map as a PNG and uploads it to the server associated with the given objective ID.
§Arguments
objective_id- The identifier of the objective to associate the exported PNG with.offset- The offset in the map to start the export.size- The dimensions of the region to export as a PNG.
§Returns
A result indicating the success or failure of the operation.
Sourcepub(crate) fn generate_zo_img_path(id: usize) -> PathBuf
pub(crate) fn generate_zo_img_path(id: usize) -> PathBuf
Sourcepub(crate) async fn upload_daily_map_png(&self) -> Result<(), Box<dyn Error>>
pub(crate) async fn upload_daily_map_png(&self) -> Result<(), Box<dyn Error>>
Uploads the daily map snapshot as a PNG to the server.
§Returns
A result indicating the success or failure of the operation.
Sourcepub(crate) async fn create_thumb_snapshot(&self) -> Result<(), Box<dyn Error>>
pub(crate) async fn create_thumb_snapshot(&self) -> Result<(), Box<dyn Error>>
Creates and saves a thumbnail snapshot of the map.
§Returns
A result indicating the success or failure of the operation.
Sourcepub(crate) async fn export_full_snapshot(&self) -> Result<(), Box<dyn Error>>
pub(crate) async fn export_full_snapshot(&self) -> Result<(), Box<dyn Error>>
Creates and saves a full-size snapshot of the map.
§Returns
A result indicating the success or failure of the operation.
Sourcepub(crate) async fn export_thumbnail_png(
&self,
offset: Vec2D<u32>,
angle: CameraAngle,
) -> Result<EncodedImageExtract, Box<dyn Error>>
pub(crate) async fn export_thumbnail_png( &self, offset: Vec2D<u32>, angle: CameraAngle, ) -> Result<EncodedImageExtract, Box<dyn Error>>
Sourcepub(crate) async fn export_full_thumbnail_png(
&self,
) -> Result<EncodedImageExtract, Box<dyn Error>>
pub(crate) async fn export_full_thumbnail_png( &self, ) -> Result<EncodedImageExtract, Box<dyn Error>>
Exports the entire map thumbnail as a PNG.
§Returns
A result containing the extracted PNG image data or an error.
Sourcepub(crate) async fn diff_thumb_snapshot(
&self,
) -> Result<EncodedImageExtract, Box<dyn Error>>
pub(crate) async fn diff_thumb_snapshot( &self, ) -> Result<EncodedImageExtract, Box<dyn Error>>
Compares the thumbnail map with its saved snapshot.
§Returns
A result containing the difference as an encoded PNG image or an error.
Sourcepub async fn execute_acquisition_cycle(
self: &Arc<Self>,
f_cont_lock: Arc<RwLock<FlightComputer>>,
console_messenger: Arc<ConsoleMessenger>,
__arg3: (DateTime<Utc>, Receiver<PeriodicImagingEndSignal>),
image_max_dt: I32F32,
start_index: usize,
) -> Vec<(isize, isize)>
pub async fn execute_acquisition_cycle( self: &Arc<Self>, f_cont_lock: Arc<RwLock<FlightComputer>>, console_messenger: Arc<ConsoleMessenger>, __arg3: (DateTime<Utc>, Receiver<PeriodicImagingEndSignal>), image_max_dt: I32F32, start_index: usize, ) -> Vec<(isize, isize)>
Executes a series of image acquisitions, processes them, and updates the associated map buffers.
§Arguments
f_cont_lock- Lock-protected flight computer controlling the acquisition cycle.console_messenger- Used for sending notifications during processing.(end_time, last_img_kill)- The end time for the cycle and a notify object to terminate the process prematurely.image_max_dt- Maximum allowed interval between consecutive images.lens- The camera angle and field of view.start_index- The starting index for tracking image acquisitions.
§Returns
A vector of completed (start, end) time ranges when images were successfully taken.
Sourcepub async fn execute_zo_target_cycle(
self: Arc<Self>,
f_cont_lock: Arc<RwLock<FlightComputer>>,
deadline: DateTime<Utc>,
zoned_objective_image_buffer: &mut Option<OffsetZonedObjectiveImage>,
offset: Vec2D<u32>,
dimensions: Vec2D<u32>,
)
pub async fn execute_zo_target_cycle( self: Arc<Self>, f_cont_lock: Arc<RwLock<FlightComputer>>, deadline: DateTime<Utc>, zoned_objective_image_buffer: &mut Option<OffsetZonedObjectiveImage>, offset: Vec2D<u32>, dimensions: Vec2D<u32>, )
Executes a series of image acquisitions, processes them, and updates an associated zoned objective buffer.
§Arguments
f_cont_lock- Lock-protected flight computer controlling the acquisition cycle.deadline- The end time for the cycle.zoned_objective_image_buffer- An optional mutable reference to anOffsetZonedObjectiveImageoffset- The offset of the buffer in the global map buffer.dimensions- The dimensions of the zoned objective.
Sourceasync fn exec_map_capture(
self: &Arc<Self>,
f_cont: &Arc<RwLock<FlightComputer>>,
p_c: &Arc<Mutex<i32>>,
lens: CameraAngle,
) -> (DateTime<Utc>, Option<Vec2D<u32>>)
async fn exec_map_capture( self: &Arc<Self>, f_cont: &Arc<RwLock<FlightComputer>>, p_c: &Arc<Mutex<i32>>, lens: CameraAngle, ) -> (DateTime<Utc>, Option<Vec2D<u32>>)
Captures a single image during mapping operation.
§Arguments
f_cont_lock- Lock-protected flight computer controlling the acquisition cycle.p_c- A shared, locked reference to the number of pictures in the current cycle.lens- The desiredCameraAnglefor this picture
§Returns
A tuple containing:
- The UTC timestamp when the image was taken
- The
Vec2D<i32>offset in the global map image buffer
Auto Trait Implementations§
impl !Freeze for CameraController
impl !RefUnwindSafe for CameraController
impl Send for CameraController
impl Sync for CameraController
impl Unpin for CameraController
impl !UnwindSafe for CameraController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.