Crates.io | gxi_hako |
lib.rs | gxi_hako |
version | 0.2.0 |
source | src |
created_at | 2024-04-26 20:37:16.963347 |
updated_at | 2024-07-15 08:11:05.184114 |
description | A rust camera interface based on Daheng-Image's GxIAPI(Galaxy Camera SDK) |
homepage | |
repository | https://github.com/zoneherobrine/gxi_hako |
max_upload_size | |
id | 1221790 |
size | 6,853,982 |
这个库基本上已经停止维护了,或者说已经被整合进了新的库之中,新的库是GXCI,它包含大恒相机SDK本地相机部分的全部原生实现,并且提供了对应的HAL封装,可以在github和crates上查看
This project is deprecated, or it has been integrated into a new project, the new project is GXCI, it's ingithub and crates, which has FULL RAW IMPLEMENTATION of the local camera part of Daheng Imaging SDK, and it provides HAL functions.
gxi_hako是一款用Rust基于GxIAPI的库进行大恒工业相机的接口开发;
目前已实现本地相机的所有接口,enums还没有完全迁移过来,并在utils内便写了一些工具类函数,方便使用
gxi_hako is developing the interface of Daheng Industrial Camera using Rust based on GxIAPI library;
At present, all interfaces for the local camera have been implemented, and the enums have not been completely migrated. Some utility functions have been written in utils to facilitate use.
The sdk-dev-doc is contained in ./doc/sdk,here I only provide the English version of the sdk-dev-doc, and the Chinese version is not provided here(Because the 10MB limitation of crates.io).
You can also get the sdk-dev-doc from the SDK of Daheng Imaging you have installed.
Following code is same as the list_devices_info.rs in the examples directory:
use std::mem::size_of;
use gxi_hako::{
gx::{
gx_interface::*,
gx_struct::*,
},
utils::{
debug::print_device_info,
builder::GXDeviceBaseInfoBuilder,
},
};
fn main() {
unsafe {
// You can change the library path as you need
let gx = GXInstance::new("C:\\Program Files\\Daheng Imaging\\GalaxySDK\\APIDll\\Win64\\GxIAPI.dll").expect("Failed to load library");
gx.gx_init_lib().expect("Failed to initialize library");
let mut device_num = 0;
gx.gx_update_device_list(&mut device_num, 1000)
.expect("Failed to update device list");
if device_num > 0 {
let mut base_info: Vec<GX_DEVICE_BASE_INFO> = (0..device_num).map(|_| {
GXDeviceBaseInfoBuilder::new().build()
}).collect();
// or you can use the following code to initialize the vector without using the builder
// let mut base_info = vec![
// GX_DEVICE_BASE_INFO {
// szVendorName: [0; GX_INFO_LENGTH_32_BYTE],
// szModelName: [0; GX_INFO_LENGTH_32_BYTE],
// szSN: [0; GX_INFO_LENGTH_32_BYTE],
// szDisplayName: [0; GX_INFO_LENGTH_128_BYTE],
// szDeviceID: [0; GX_INFO_LENGTH_64_BYTE],
// szUserID: [0; GX_INFO_LENGTH_64_BYTE],
// accessStatus: GX_ACCESS_STATUS_CMD::Unknown,
// deviceClass: GX_DEVICE_CLASS::Unknown,
// reserved: [0; 300],
// };
// device_num as usize
// ];
let mut size = (device_num as usize) * size_of::<GX_DEVICE_BASE_INFO>();
let status = gx
.gx_get_all_device_base_info(base_info.as_mut_ptr(), &mut size)
.expect("Failed to get all device base info");
if status == 0 {
// Assuming 0 is GX_STATUS_SUCCESS
println!(
"Device base info retrieved successfully. Number of devices: {}",
device_num
);
for device in &base_info {
print_device_info(&device);
}
} else {
println!("Failed to retrieve device base info, status: {}", status);
}
} else {
println!("No Devices found.");
}
gx.gx_close_lib().expect("Failed to close library");
println!("Library closed.")
}
}
You can see the GXInstance part(where impl the GXInterface trait with rust-doc) in gx_interface doc , the link is here
Here 5 examples are provided, which are:
You can run the example by the following command:
cargo run --example list_devices_info
The OpenCV lib here is only used to easily provide a GUI to show the image, so you can ignore this part if you don't want to show the image.
In Windows 10/11, I would like using choco as the following command to install LLVM and OpenCV 4.9.0:
choco install llvm opencv
Following are the websites:
You can add the following path to the path environment variable:
Here is an example:
D:\ProgramUnsigned\Embedded\opencv\build\bin
D:\ProgramUnsigned\Embedded\opencv\build\x64\vc16\bin
C:\ProgramData\chocolatey\bin
C:\Program Files\LLVM\bin
OPENCV_INCLUDE_PATHS ...\opencv\build\include OPENCV_LINK_LIBS opencv_world490 OPENCV_LINK_PATHS ...\opencv\build\x64\vc16\lib
here is an example:
OPENCV_INCLUDE_PATHS D:\ProgramUnsigned\Embedded\opencv\build\include
OPENCV_LINK_LIBS opencv_world490
OPENCV_LINK_PATHS D:\ProgramUnsigned\Embedded\opencv\build\x64\vc16\lib
Sometimes, you need to copy the opencv_world490.dll to the target directory, which is the same as the exe file.
You also need to install the GxIAPI SDK, which can be downloaded from the official website.
Just install the SDK for your platform.
You need to connect the camera to your computer, and make sure the camera is powered on.
Then all the environment is ready.
USB3.0 Camera
Gige Camera
Now, is Windows only.
Licensed under the MIT License.
Uhmmm... placeholder
pLaShOlDeR~