gxi_hako/
lib.rs

1//! This library provides a rust interface to the GX API (Daheng Camera).
2//! 
3//! # Quick Start
4//! 
5//! ```rust
6//! use std::mem::size_of;
7//! use gxi_hako::{
8//!    gx::{
9//!         gx_interface::*,
10//!         gx_enum::*,
11//!         gx_struct::*,
12//!         gx_handle::*,
13//!     },
14//!     utils::{
15//!         debug::print_device_info,
16//!         builder::GXDeviceBaseInfoBuilder,
17//!     }
18//! };
19//! 
20//! fn main() {
21//!     unsafe {
22//!         // You can change the library path as you need
23//!         let gx = GXInstance::new("C:\\Program Files\\Daheng Imaging\\GalaxySDK\\APIDll\\Win64\\GxIAPI.dll").expect("Failed to load library");
24//!     
25//!         gx.gx_init_lib().expect("Failed to initialize library");
26//!     
27//!         let mut device_num = 0;
28//!         gx.gx_update_device_list(&mut device_num, 1000)
29//!             .expect("Failed to update device list");
30//!     
31//!         if device_num > 0 {
32//!             let mut base_info: Vec<GX_DEVICE_BASE_INFO> = (0..device_num).map(|_| {
33//!                 GXDeviceBaseInfoBuilder::new().build()
34//!             }).collect();
35//!             let mut size = (device_num as usize) * size_of::<GX_DEVICE_BASE_INFO>();
36//!             let status = gx
37//!                 .gx_get_all_device_base_info(base_info.as_mut_ptr(), &mut size)
38//!                 .expect("Failed to get all device base info");
39//!             if status == 0 {
40//!                 // Assuming 0 is GX_STATUS_SUCCESS
41//!                 println!(
42//!                     "Device base info retrieved successfully. Number of devices: {}",
43//!                     device_num
44//!                 );
45//!                 for device in &base_info {
46//!                     print_device_info(&device);
47//!                 }
48//!             } else {
49//!                 println!("Failed to retrieve device base info, status: {}", status);
50//!             }
51//!         } else {
52//!             println!("No Devices found.");
53//!         }
54//!         gx.gx_close_lib().expect("Failed to close library");
55//!         println!("Library closed.")
56//!     }
57//! }
58//! ```
59//! 
60//! # Feature Overview
61//! 
62//! ## GX
63//! 
64//! The gx module contains the following modules:
65//! - gx_const: Contains the constants used in the GX API.
66//! - gx_callback: Contains the callback function for the frame data.
67//! - gx_enum: Contains the enums used in the GX API.
68//! - gx_handle: Contains the handle for the GX API.
69//! - gx_interface: Contains the interface for the GX API. All functions are defined here in the GXInterface trait.
70//! - gx_pixel_format: Contains the pixel format for the GX API.
71//! - gx_struct: Contains the structs used in the GX API.
72//! 
73//! 
74//! ## Utils
75//! 
76//! The utils module contains the following modules:
77//! - builder: Contains the builder pattern for creating the GXDeviceBaseInfo and GXOpenParam structs.
78//! - cv_gui: Contains the functions for displaying images using OpenCV.
79//! - debug: Contains the function for printing the device information.
80//! - facade: Contains the GXFrameDataFacade struct which is used to manage the frame data.
81//! - image_process: Contains the functions for processing images.
82//! - status: Contains the status codes converter for the GX API.
83//! 
84//! 
85
86pub mod gx {
87    pub mod gx_const;
88    pub mod gx_callback;
89    pub mod gx_enum;
90    pub mod gx_handle;
91    pub mod gx_interface;
92    pub mod gx_pixel_format;
93    pub mod gx_struct;
94}
95
96pub mod utils {
97    pub mod builder;
98    pub mod cv_gui;
99    pub mod image_process;
100    pub mod debug;
101    pub mod facade;
102    pub mod status;
103}
104
105pub use gx::{
106    gx_interface::{GXInstance,GXInterface}, 
107    gx_enum::*,
108    gx_struct::*,
109
110};
111
112pub use utils::{
113    builder::{GXDeviceBaseInfoBuilder,GXOpenParamBuilder},
114    debug::print_device_info,
115    facade::GXFrameDataFacade,
116    
117};