summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Cargo.toml9
-rw-r--r--build.rs24
-rwxr-xr-xinclude/asi/ASICamera2.h821
-rwxr-xr-xlib/README.txt13
-rw-r--r--lib/armv5/libASICamera2.abin0 -> 2796192 bytes
l---------lib/armv5/libASICamera2.so1
-rwxr-xr-xlib/armv5/libASICamera2.so.1.13.0930bin0 -> 1712638 bytes
-rw-r--r--lib/armv6/libASICamera2.abin0 -> 2537816 bytes
l---------lib/armv6/libASICamera2.so1
-rwxr-xr-xlib/armv6/libASICamera2.so.1.13.0930bin0 -> 1560231 bytes
-rw-r--r--lib/armv7/libASICamera2.abin0 -> 2266780 bytes
l---------lib/armv7/libASICamera2.so1
-rwxr-xr-xlib/armv7/libASICamera2.so.1.13.0930bin0 -> 1296159 bytes
-rw-r--r--lib/armv8/libASICamera2.abin0 -> 3272552 bytes
l---------lib/armv8/libASICamera2.so1
-rwxr-xr-xlib/armv8/libASICamera2.so.1.13.0930bin0 -> 1784822 bytes
-rwxr-xr-xlib/asi.rules3
-rw-r--r--lib/mac/libASICamera2.abin0 -> 4973896 bytes
l---------lib/mac/libASICamera2.dylib1
-rwxr-xr-xlib/mac/libASICamera2.dylib.1.13.0930bin0 -> 2967648 bytes
-rw-r--r--lib/x64/libASICamera2.abin0 -> 3354576 bytes
-rwxr-xr-xlib/x64/libASICamera2.sobin0 -> 1799059 bytes
l---------lib/x64/libASICamera2.sobut_actually_a_symlink1
-rw-r--r--lib/x86/libASICamera2.abin0 -> 2757456 bytes
l---------lib/x86/libASICamera2.so1
-rwxr-xr-xlib/x86/libASICamera2.so.1.13.0930bin0 -> 1799009 bytes
-rw-r--r--src/asicam/ASICamera2.rs945
-rw-r--r--src/asicam/mod.rs282
-rw-r--r--src/main.rs76
30 files changed, 2182 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..53eaa21
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target
+**/*.rs.bk
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..214702d
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "calibration_collector"
+version = "0.1.0"
+authors = ["iximeow <me@iximeow.net>"]
+edition = "2018"
+build = "build.rs"
+
+[dependencies]
+"png" = "0.13.2"
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..da6c74c
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,24 @@
+use std::collections::HashMap;
+use std::env;
+
+fn main() {
+ let target = env::var("TARGET").unwrap();
+ if !target.contains("linux") {
+ panic!("Non-linux build targets are not tested and may not have a corresponding driver at the moment.");
+ }
+
+ let mut archmap: HashMap<&'static str, &'static str> = HashMap::new();
+ archmap.insert("x86_64", "x64");
+ archmap.insert("x86", "x86");
+ archmap.insert("armv5", "armv5");
+ archmap.insert("armv6", "armv6");
+ archmap.insert("armv7", "armv7");
+ archmap.insert("armv8", "armv8");
+ for (arch, dir) in archmap.iter() {
+ if target.contains(arch) {
+ println!("cargo:rustc-link-search={}/lib/{}/", env::var("CARGO_MANIFEST_DIR").unwrap(), dir);
+ }
+ }
+ println!("cargo:rustc-link-lib=ASICamera2");
+ println!("cargo:rustc-link-lib=qhyccd");
+}
diff --git a/include/asi/ASICamera2.h b/include/asi/ASICamera2.h
new file mode 100755
index 0000000..93a873c
--- /dev/null
+++ b/include/asi/ASICamera2.h
@@ -0,0 +1,821 @@
+/**************************************************
+this is the second version of release ASI Camera ASIs
+any question feel free contact us:sam.wen@zwoptical.com
+
+here is the suggested procedure to operate the camera.
+
+--> ASIGetNumOfConnectedCameras
+----> ASIGetCameraProperty for each camera
+
+--> ASIOpenCamera
+--> ASIInitCamera
+--> ASIGetNumOfControls
+----> ASIGetControlCaps for each contronl and set or get value from them
+
+--> ASISetROIFormat
+
+--> ASISetCameraMode
+
+--> ASIStartVideoCapture
+
+//this is recommended to do in another thread
+while(1)
+{
+ ASIGetVideoData
+ ...
+}
+
+
+***************************************************/
+#ifndef ASICAMERA2_H
+#define ASICAMERA2_H
+
+
+
+
+#ifdef _WINDOWS
+ #define ASICAMERA_API __declspec(dllexport)
+#else
+ #define ASICAMERA_API
+#endif
+
+#define ASICAMERA_ID_MAX 128
+
+typedef enum ASI_BAYER_PATTERN{
+ ASI_BAYER_RG=0,
+ ASI_BAYER_BG,
+ ASI_BAYER_GR,
+ ASI_BAYER_GB
+}ASI_BAYER_PATTERN;
+
+typedef enum ASI_IMG_TYPE{ //Supported Video Format
+ ASI_IMG_RAW8 = 0,
+ ASI_IMG_RGB24,
+ ASI_IMG_RAW16,
+ ASI_IMG_Y8,
+ ASI_IMG_END = -1
+
+}ASI_IMG_TYPE;
+
+typedef enum ASI_GUIDE_DIRECTION{ //Guider Direction
+ ASI_GUIDE_NORTH=0,
+ ASI_GUIDE_SOUTH,
+ ASI_GUIDE_EAST,
+ ASI_GUIDE_WEST
+}ASI_GUIDE_DIRECTION;
+
+
+
+typedef enum ASI_FLIP_STATUS {
+ ASI_FLIP_NONE = 0,//: original
+ ASI_FLIP_HORIZ,//: horizontal flip
+ ASI_FLIP_VERT,// vertical flip
+ ASI_FLIP_BOTH,//:both horizontal and vertical flip
+
+}ASI_FLIP_STATUS;
+
+typedef enum ASI_CAMERA_MODE {
+ ASI_MODE_NORMAL = 0,
+ ASI_MODE_TRIG_SOFT_EDGE,
+ ASI_MODE_TRIG_RISE_EDGE,
+ ASI_MODE_TRIG_FALL_EDGE,
+ ASI_MODE_TRIG_SOFT_LEVEL,
+ ASI_MODE_TRIG_HIGH_LEVEL,
+ ASI_MODE_TRIG_LOW_LEVEL,
+ ASI_MODE_END = -1
+}ASI_CAMERA_MODE;
+
+typedef enum ASI_ERROR_CODE{ //ASI ERROR CODE
+ ASI_SUCCESS=0,
+ ASI_ERROR_INVALID_INDEX, //no camera connected or index value out of boundary
+ ASI_ERROR_INVALID_ID, //invalid ID
+ ASI_ERROR_INVALID_CONTROL_TYPE, //invalid control type
+ ASI_ERROR_CAMERA_CLOSED, //camera didn't open
+ ASI_ERROR_CAMERA_REMOVED, //failed to find the camera, maybe the camera has been removed
+ ASI_ERROR_INVALID_PATH, //cannot find the path of the file
+ ASI_ERROR_INVALID_FILEFORMAT,
+ ASI_ERROR_INVALID_SIZE, //wrong video format size
+ ASI_ERROR_INVALID_IMGTYPE, //unsupported image formate
+ ASI_ERROR_OUTOF_BOUNDARY, //the startpos is out of boundary
+ ASI_ERROR_TIMEOUT, //timeout
+ ASI_ERROR_INVALID_SEQUENCE,//stop capture first
+ ASI_ERROR_BUFFER_TOO_SMALL, //buffer size is not big enough
+ ASI_ERROR_VIDEO_MODE_ACTIVE,
+ ASI_ERROR_EXPOSURE_IN_PROGRESS,
+ ASI_ERROR_GENERAL_ERROR,//general error, eg: value is out of valid range
+ ASI_ERROR_INVALID_MODE,//the current mode is wrong
+ ASI_ERROR_END
+}ASI_ERROR_CODE;
+
+typedef enum ASI_BOOL{
+ ASI_FALSE =0,
+ ASI_TRUE
+}ASI_BOOL;
+
+typedef struct _ASI_CAMERA_INFO
+{
+ char Name[64]; //the name of the camera, you can display this to the UI
+ int CameraID; //this is used to control everything of the camera in other functions.Start from 0.
+ long MaxHeight; //the max height of the camera
+ long MaxWidth; //the max width of the camera
+
+ ASI_BOOL IsColorCam;
+ ASI_BAYER_PATTERN BayerPattern;
+
+ int SupportedBins[16]; //1 means bin1 which is supported by every camera, 2 means bin 2 etc.. 0 is the end of supported binning method
+ ASI_IMG_TYPE SupportedVideoFormat[8]; //this array will content with the support output format type.IMG_END is the end of supported video format
+
+ double PixelSize; //the pixel size of the camera, unit is um. such like 5.6um
+ ASI_BOOL MechanicalShutter;
+ ASI_BOOL ST4Port;
+ ASI_BOOL IsCoolerCam;
+ ASI_BOOL IsUSB3Host;
+ ASI_BOOL IsUSB3Camera;
+ float ElecPerADU;
+ int BitDepth;
+ ASI_BOOL IsTriggerCam;
+
+ char Unused[16];
+} ASI_CAMERA_INFO;
+
+#define ASI_BRIGHTNESS ASI_OFFSET
+#define ASI_AUTO_MAX_BRIGHTNESS ASI_AUTO_TARGET_BRIGHTNESS
+
+typedef enum ASI_CONTROL_TYPE{ //Control type//
+ ASI_GAIN = 0,
+ ASI_EXPOSURE,
+ ASI_GAMMA,
+ ASI_WB_R,
+ ASI_WB_B,
+ ASI_OFFSET,
+ ASI_BANDWIDTHOVERLOAD,
+ ASI_OVERCLOCK,
+ ASI_TEMPERATURE,// return 10*temperature
+ ASI_FLIP,
+ ASI_AUTO_MAX_GAIN,
+ ASI_AUTO_MAX_EXP,//micro second
+ ASI_AUTO_TARGET_BRIGHTNESS,//target brightness
+ ASI_HARDWARE_BIN,
+ ASI_HIGH_SPEED_MODE,
+ ASI_COOLER_POWER_PERC,
+ ASI_TARGET_TEMP,// not need *10
+ ASI_COOLER_ON,
+ ASI_MONO_BIN,//lead to less grid at software bin mode for color camera
+ ASI_FAN_ON,
+ ASI_PATTERN_ADJUST,
+ ASI_ANTI_DEW_HEATER,
+
+}ASI_CONTROL_TYPE;
+
+typedef struct _ASI_CONTROL_CAPS
+{
+ char Name[64]; //the name of the Control like Exposure, Gain etc..
+ char Description[128]; //description of this control
+ long MaxValue;
+ long MinValue;
+ long DefaultValue;
+ ASI_BOOL IsAutoSupported; //support auto set 1, don't support 0
+ ASI_BOOL IsWritable; //some control like temperature can only be read by some cameras
+ ASI_CONTROL_TYPE ControlType;//this is used to get value and set value of the control
+ char Unused[32];
+} ASI_CONTROL_CAPS;
+
+typedef enum ASI_EXPOSURE_STATUS {
+ ASI_EXP_IDLE = 0,//: idle states, you can start exposure now
+ ASI_EXP_WORKING,//: exposing
+ ASI_EXP_SUCCESS,//: exposure finished and waiting for download
+ ASI_EXP_FAILED,//:exposure failed, you need to start exposure again
+
+}ASI_EXPOSURE_STATUS;
+
+typedef struct _ASI_ID{
+ unsigned char id[8];
+}ASI_ID;
+
+typedef struct _ASI_SUPPORTED_MODE{
+ ASI_CAMERA_MODE SupportedCameraMode[16];// this array will content with the support camera mode type.ASI_MODE_END is the end of supported camera mode
+}ASI_SUPPORTED_MODE;
+
+#ifndef __cplusplus
+#define ASI_CONTROL_TYPE int
+#define ASI_BOOL int
+#define ASI_ERROR_CODE int
+#define ASI_FLIP_STATUS int
+#define ASI_IMG_TYPE int
+#define ASI_GUIDE_DIRECTION int
+#define ASI_BAYER_PATTERN int
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************************************************************
+Descriptions£º
+this should be the first API to be called
+get number of connected ASI cameras,
+
+Paras£º
+
+return£ºnumber of connected ASI cameras. 1 means 1 camera connected.
+***************************************************************************/
+ASICAMERA_API int ASIGetNumOfConnectedCameras();
+
+/***************************************************************************
+Descriptions:
+get the product ID of each supported camera, at first set pPIDs as 0 and get length and then malloc a buffer to contain the PIDs
+
+Paras:
+int* pPIDs: pointer to array of PIDs
+
+Return: length of the array.
+***************************************************************************/
+ASICAMERA_API int ASIGetProductIDs(int* pPIDs);
+
+/***************************************************************************
+Descriptions£º
+get the property of the connected cameras, you can do this without open the camera.
+here is the sample code:
+
+int iNumofConnectCameras = ASIGetNumOfConnectedCameras();
+ASI_CAMERA_INFO **ppASICameraInfo = (ASI_CAMERA_INFO **)malloc(sizeof(ASI_CAMERA_INFO *)*iNumofConnectCameras);
+for(int i = 0; i < iNumofConnectCameras; i++)
+{
+ppASICameraInfo[i] = (ASI_CAMERA_INFO *)malloc(sizeof(ASI_CAMERA_INFO ));
+ASIGetCameraProperty(ppASICameraInfo[i], i);
+}
+
+Paras£º
+ ASI_CAMERA_INFO *pASICameraInfo: Pointer to structure containing the property of camera
+ user need to malloc the buffer
+ int iCameraIndex: 0 means the first connect camera, 1 means the second connect camera
+
+return£º
+ ASI_SUCCESS: Operation is successful
+ ASI_ERROR_INVALID_INDEX :no camera connected or index value out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetCameraProperty(ASI_CAMERA_INFO *pASICameraInfo, int iCameraIndex);
+
+/***************************************************************************
+Descriptions£º
+ open the camera before any operation to the camera, this will not affect the camera which is capturing
+ All APIs below need to open the camera at first.
+
+Paras£º
+ int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return£º
+ASI_SUCCESS: Operation is successful
+ASI_ERROR_INVALID_ID : no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_CAMERA_REMOVED: failed to find the camera, maybe camera has been removed
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIOpenCamera(int iCameraID);
+
+/***************************************************************************
+Descriptions
+
+ Initialise the camera after open, this function may take some while, this will affect the camera which is capturing
+
+Paras£º
+ int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIInitCamera(int iCameraID);
+
+/***************************************************************************
+Descriptions£º
+you need to close the camera to free all the resource
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return£º
+ASI_SUCCESS :it will return success even the camera already closed
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASICloseCamera(int iCameraID);
+
+
+
+
+/***************************************************************************
+Descriptions£º
+Get number of controls available for this camera. the camera need be opened at first.
+
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int * piNumberOfControls: pointer to an int to save the number of controls
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetNumOfControls(int iCameraID, int * piNumberOfControls);
+
+
+/***************************************************************************
+Descriptions£º
+Get controls property available for this camera. the camera need be opened at first.
+user need to malloc and maintain the buffer.
+
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int iControlIndex: index of control, NOT control type
+ASI_CONTROL_CAPS * pControlCaps: Pointer to structure containing the property of the control
+user need to malloc the buffer
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetControlCaps(int iCameraID, int iControlIndex, ASI_CONTROL_CAPS * pControlCaps);
+
+/***************************************************************************
+Descriptions£º
+Get controls property value and auto value
+note:the value of the temperature is the float value * 10 to convert it to long type, control name is "Temperature"
+because long is the only type for control(except cooler's target temperature, because it is an integer)
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int ControlType: this is get from control property use the API ASIGetControlCaps
+long *plValue: pointer to the value you want to save the value get from control
+ASI_BOOL *pbAuto: pointer to the ASI_BOOL type
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetControlValue(int iCameraID, ASI_CONTROL_TYPE ControlType, long *plValue, ASI_BOOL *pbAuto);
+
+/***************************************************************************
+Descriptions£º
+Set controls property value and auto value
+it will return success and set the max value or min value if the value is beyond the boundary
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int ControlType: this is get from control property use the API ASIGetControlCaps
+long lValue: the value set to the control
+ASI_BOOL bAuto: set the control auto
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type
+ASI_ERROR_GENERAL_ERROR,//general error, eg: value is out of valid range; operate to camera hareware failed
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISetControlValue(int iCameraID, ASI_CONTROL_TYPE ControlType, long lValue, ASI_BOOL bAuto);
+
+
+
+/***************************************************************************
+Descriptions£º
+set the ROI area before capture.
+you must stop capture before call it.
+the width and height is the value after binning.
+ie. you need to set width to 640 and height to 480 if you want to run at 640X480@BIN2
+ASI120's data size must be times of 1024 which means width*height%1024=0
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int iWidth, the width of the ROI area. Make sure iWidth%8 = 0.
+int iHeight, the height of the ROI area. Make sure iHeight%2 = 0,
+further, for USB2.0 camera ASI120, please make sure that iWidth*iHeight%1024=0.
+int iBin, binning method. bin1=1, bin2=2
+ASI_IMG_TYPE Img_type: the output format you want
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_INVALID_SIZE, //wrong video format size
+ASI_ERROR_INVALID_IMGTYPE, //unsupported image format, make sure iWidth and iHeight and binning is set correct
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISetROIFormat(int iCameraID, int iWidth, int iHeight, int iBin, ASI_IMG_TYPE Img_type);
+
+
+/***************************************************************************
+Descriptions£º
+Get the current ROI area setting .
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int *piWidth, pointer to the width of the ROI area
+int *piHeight, pointer to the height of the ROI area.
+int *piBin, pointer to binning method. bin1=1, bin2=2
+ASI_IMG_TYPE *pImg_type: pointer to the output format
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetROIFormat(int iCameraID, int *piWidth, int *piHeight, int *piBin, ASI_IMG_TYPE *pImg_type);
+
+
+/***************************************************************************
+Descriptions£º
+Set the start position of the ROI area.
+you can call this API to move the ROI area when video is streaming
+the camera will set the ROI area to the center of the full image as default
+at bin2 or bin3 mode, the position is relative to the image after binning
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int iStartX, pointer to the start X
+int iStartY pointer to the start Y
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_OUTOF_BOUNDARY: the start x and start y make the image out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISetStartPos(int iCameraID, int iStartX, int iStartY);
+
+/***************************************************************************
+Descriptions£º
+Get the start position of current ROI area .
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int *piStartX, pointer to the start X
+int *piStartY pointer to the start Y
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetStartPos(int iCameraID, int *piStartX, int *piStartY);
+
+/***************************************************************************
+Descriptions£º
+Get the droped frames .
+drop frames happen when USB is traffic or harddisk write speed is slow
+it will reset to 0 after stop capture
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+int *piDropFrames pointer to drop frames
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetDroppedFrames(int iCameraID,int *piDropFrames);
+
+/***************************************************************************
+Descriptions£º
+provide a dark file's path to the function and enable dark subtract
+this is used when there is hot pixel or need to do long exposure
+you'd better make this dark file from the "dark subtract" funtion
+of the "video capture filter" directshow page.
+the dark file's size should be the same of camera's max width and height
+and should be RGB8 raw format.it will on even you changed the ROI setting
+it only correct the hot pixels if out put isn't 16bit.
+
+it will be remembered in registry. so "Dark subtract" is on next time if you close your app.
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+char *pcBMPPath: the path to the bmp dark file.
+return£º
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_PATH, //cannot find the path of the file
+ASI_ERROR_INVALID_FILEFORMAT, //the dark file's size should be the same of camera's max width and height
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIEnableDarkSubtract(int iCameraID, char *pcBMPPath);
+
+/***************************************************************************
+Descriptions£º
+Disable the dark subtract function.
+you'd better call it at start if you don't want to use it.
+because dark subtract function is remembered on windows platform
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIDisableDarkSubtract(int iCameraID);
+
+/***************************************************************************
+Descriptions£º
+Start video capture
+then you can get the data from the API ASIGetVideoData
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return:
+ASI_SUCCESS : Operation is successful, it will return success if already started
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_EXPOSURE_IN_PROGRESS: snap mode is working, you need to stop snap first
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIStartVideoCapture(int iCameraID);
+
+/***************************************************************************
+Descriptions£º
+Stop video capture
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+return:
+ASI_SUCCESS : Operation is successful, it will return success if already stopped
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIStopVideoCapture(int iCameraID);
+
+/***************************************************************************
+Descriptions£º
+get data from the video buffer.the buffer is very small
+you need to call this API as fast as possible, otherwise frame will be discarded
+so the best way is maintain one buffer loop and call this API in a loop
+please make sure the buffer size is biger enough to hold one image
+otherwise the this API will crash
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+unsigned char* pBuffer, caller need to malloc the buffer, make sure the size is big enough
+ the size in byte:
+ 8bit mono:width*height
+ 16bit mono:width*height*2
+ RGB24:width*height*3
+
+int iWaitms, this API will block and wait iWaitms to get one image. the unit is ms
+ -1 means wait forever. this value is recommend set to exposure*2+500ms
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_TIMEOUT: no image get and timeout
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetVideoData(int iCameraID, unsigned char* pBuffer, long lBuffSize, int iWaitms);
+
+
+/***************************************************************************
+Descriptions£º
+PulseGuide of the ST4 port on. this function only work on the module which have ST4 port
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_GUIDE_DIRECTION direction the direction of guider
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIPulseGuideOn(int iCameraID, ASI_GUIDE_DIRECTION direction);
+
+/***************************************************************************
+Descriptions£º
+PulseGuide of the ST4 port off. this function only work on the module which have ST4 port
+make sure where is ASIPulseGuideOn and there is ASIPulseGuideOff
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_GUIDE_DIRECTION direction the direction of guider
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIPulseGuideOff(int iCameraID, ASI_GUIDE_DIRECTION direction);
+
+
+/***************************************************************************
+Descriptions£º
+Start camera exposure. the following 4 API is usually used when long exposure required
+start exposure and check the exposure status then get the data
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_BOOL bIsDark: means dark frame if there is mechanical shutter on the camera. otherwise useless
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_VIDEO_MODE_ACTIVE: video mode is working, you need to stop video capture first
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIStartExposure(int iCameraID, ASI_BOOL bIsDark);
+
+/***************************************************************************
+Descriptions£º
+to cancel the long exposure which is on.
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIStopExposure(int iCameraID);
+
+/***************************************************************************
+Descriptions£º
+to get the exposure status, work with ASIStartExposure.
+you can read the data if get ASI_EXP_SUCCESS. or have to restart exposure again
+if get ASI_EXP_FAILED
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_EXPOSURE_STATUS *pExpStatus: the exposure status
+
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+
+***************************************************************************/
+
+ASICAMERA_API ASI_ERROR_CODE ASIGetExpStatus(int iCameraID, ASI_EXPOSURE_STATUS *pExpStatus);
+
+/***************************************************************************
+Descriptions£º
+get data after exposure.
+please make sure the buffer size is biger enough to hold one image
+otherwise the this API will crash
+
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+unsigned char* pBuffer, caller need to malloc the buffer, make sure the size is big enough
+the size in byte:
+8bit mono:width*height
+16bit mono:width*height*2
+RGB24:width*height*3
+
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+ASI_ERROR_TIMEOUT: no image get and timeout
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetDataAfterExp(int iCameraID, unsigned char* pBuffer, long lBuffSize);
+
+/***************************************************************************
+Descriptions£º
+get camera id stored in flash, only available for USB3.0 camera
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_ID* pID: pointer to ID
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetID(int iCameraID, ASI_ID* pID);
+
+/***************************************************************************
+Descriptions£º
+write camera id to flash, only available for USB3.0 camera
+
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_ID ID: ID
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISetID(int iCameraID, ASI_ID ID);
+
+/***************************************************************************
+Descriptions£º
+get pre-setting parameter
+Paras£º
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+Offset_HighestDR: offset at highest dynamic range,
+Offset_UnityGain: offset at unity gain
+int *Gain_LowestRN, *Offset_LowestRN: gain and offset at lowest read noise
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetGainOffset(int iCameraID, int *pOffset_HighestDR, int *pOffset_UnityGain, int *pGain_LowestRN, int *pOffset_LowestRN);
+
+/***************************************************************************
+Descriptions£º
+get version string, like "1, 13, 0503"
+***************************************************************************/
+ASICAMERA_API char* ASIGetSDKVersion();
+
+/***************************************************************************
+Description:
+Get the camera supported mode, only need to call when the IsTriggerCam in the CameraInfo is true.
+Paras:
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_SUPPORTED_MODE: the camera supported mode
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetCameraSupportMode(int iCameraID, ASI_SUPPORTED_MODE* pSupportedMode);
+
+/***************************************************************************
+Description:
+Get the camera current mode, only need to call when the IsTriggerCam in the CameraInfo is true
+Paras:
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_CAMERA_MODE: the current camera mode
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASIGetCameraMode(int iCameraID, ASI_CAMERA_MODE* mode);
+
+/***************************************************************************
+Description:
+Set the camera mode, only need to call when the IsTriggerCam in the CameraInfo is true
+Paras:
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_CAMERA_MODE: this is get from the camera property use the API ASIGetCameraProperty
+
+return:
+ASI_SUCCESS : Operation is successful
+ASI_ERROR_CAMERA_CLOSED : camera didn't open
+ASI_ERROR_INVALID_SEQUENCE : camera is in capture now, need to stop capture first.
+ASI_ERROR_INVALID_MODE : mode is out of boundary or this camera do not support this mode
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISetCameraMode(int iCameraID, ASI_CAMERA_MODE mode);
+
+/***************************************************************************
+Description:
+Send out a softTrigger. For edge trigger, it only need to set true which means send a
+rising trigger to start exposure. For level trigger, it need to set true first means
+start exposure, and set false means stop exposure.it only need to call when the
+IsTriggerCam in the CameraInfo is true
+Paras:
+int CameraID: this is get from the camera property use the API ASIGetCameraProperty
+ASI_BOOL starts:send a softTrigger start/stop signal
+***************************************************************************/
+ASICAMERA_API ASI_ERROR_CODE ASISendSoftTrigger(int iCameraID, ASI_BOOL bStart);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/README.txt b/lib/README.txt
new file mode 100755
index 0000000..96eaa5f
--- /dev/null
+++ b/lib/README.txt
@@ -0,0 +1,13 @@
+Applicable platform:
+ubuntu:x86, x64
+armv6: raspberry pi
+armv5: armv5 Soft-Float
+mac os: mac
+armv7: raspberry pi2
+armv8: arm 64bit
+
+$ sudo install asi.rules /lib/udev/rules.d
+or
+$ sudo install asi.rules /etc/udev/rules.d
+and reconnect camera, then the camera can be opened without root
+and run 'cat /sys/module/usbcore/parameters/usbfs_memory_mb' to make sure the result is 200
diff --git a/lib/armv5/libASICamera2.a b/lib/armv5/libASICamera2.a
new file mode 100644
index 0000000..d7f797c
--- /dev/null
+++ b/lib/armv5/libASICamera2.a
Binary files differ
diff --git a/lib/armv5/libASICamera2.so b/lib/armv5/libASICamera2.so
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/armv5/libASICamera2.so
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/armv5/libASICamera2.so.1.13.0930 b/lib/armv5/libASICamera2.so.1.13.0930
new file mode 100755
index 0000000..cbe9e9c
--- /dev/null
+++ b/lib/armv5/libASICamera2.so.1.13.0930
Binary files differ
diff --git a/lib/armv6/libASICamera2.a b/lib/armv6/libASICamera2.a
new file mode 100644
index 0000000..0db5ba2
--- /dev/null
+++ b/lib/armv6/libASICamera2.a
Binary files differ
diff --git a/lib/armv6/libASICamera2.so b/lib/armv6/libASICamera2.so
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/armv6/libASICamera2.so
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/armv6/libASICamera2.so.1.13.0930 b/lib/armv6/libASICamera2.so.1.13.0930
new file mode 100755
index 0000000..bf78ef6
--- /dev/null
+++ b/lib/armv6/libASICamera2.so.1.13.0930
Binary files differ
diff --git a/lib/armv7/libASICamera2.a b/lib/armv7/libASICamera2.a
new file mode 100644
index 0000000..63633c2
--- /dev/null
+++ b/lib/armv7/libASICamera2.a
Binary files differ
diff --git a/lib/armv7/libASICamera2.so b/lib/armv7/libASICamera2.so
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/armv7/libASICamera2.so
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/armv7/libASICamera2.so.1.13.0930 b/lib/armv7/libASICamera2.so.1.13.0930
new file mode 100755
index 0000000..35a93b0
--- /dev/null
+++ b/lib/armv7/libASICamera2.so.1.13.0930
Binary files differ
diff --git a/lib/armv8/libASICamera2.a b/lib/armv8/libASICamera2.a
new file mode 100644
index 0000000..8279d42
--- /dev/null
+++ b/lib/armv8/libASICamera2.a
Binary files differ
diff --git a/lib/armv8/libASICamera2.so b/lib/armv8/libASICamera2.so
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/armv8/libASICamera2.so
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/armv8/libASICamera2.so.1.13.0930 b/lib/armv8/libASICamera2.so.1.13.0930
new file mode 100755
index 0000000..cd28d1a
--- /dev/null
+++ b/lib/armv8/libASICamera2.so.1.13.0930
Binary files differ
diff --git a/lib/asi.rules b/lib/asi.rules
new file mode 100755
index 0000000..579503b
--- /dev/null
+++ b/lib/asi.rules
@@ -0,0 +1,3 @@
+ACTION=="add", ATTR{idVendor}=="03c3", RUN+="/bin/sh -c '/bin/echo 200 >/sys/module/usbcore/parameters/usbfs_memory_mb'"
+# All ASI Cameras and filter wheels
+SUBSYSTEMS=="usb", ATTR{idVendor}=="03c3", MODE="0666"
diff --git a/lib/mac/libASICamera2.a b/lib/mac/libASICamera2.a
new file mode 100644
index 0000000..45e81a8
--- /dev/null
+++ b/lib/mac/libASICamera2.a
Binary files differ
diff --git a/lib/mac/libASICamera2.dylib b/lib/mac/libASICamera2.dylib
new file mode 120000
index 0000000..8c31f99
--- /dev/null
+++ b/lib/mac/libASICamera2.dylib
@@ -0,0 +1 @@
+libASICamera2.dylib.1.13.0930 \ No newline at end of file
diff --git a/lib/mac/libASICamera2.dylib.1.13.0930 b/lib/mac/libASICamera2.dylib.1.13.0930
new file mode 100755
index 0000000..3516d53
--- /dev/null
+++ b/lib/mac/libASICamera2.dylib.1.13.0930
Binary files differ
diff --git a/lib/x64/libASICamera2.a b/lib/x64/libASICamera2.a
new file mode 100644
index 0000000..2a36a9b
--- /dev/null
+++ b/lib/x64/libASICamera2.a
Binary files differ
diff --git a/lib/x64/libASICamera2.so b/lib/x64/libASICamera2.so
new file mode 100755
index 0000000..4a3a7c9
--- /dev/null
+++ b/lib/x64/libASICamera2.so
Binary files differ
diff --git a/lib/x64/libASICamera2.sobut_actually_a_symlink b/lib/x64/libASICamera2.sobut_actually_a_symlink
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/x64/libASICamera2.sobut_actually_a_symlink
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/x86/libASICamera2.a b/lib/x86/libASICamera2.a
new file mode 100644
index 0000000..95f4753
--- /dev/null
+++ b/lib/x86/libASICamera2.a
Binary files differ
diff --git a/lib/x86/libASICamera2.so b/lib/x86/libASICamera2.so
new file mode 120000
index 0000000..7484397
--- /dev/null
+++ b/lib/x86/libASICamera2.so
@@ -0,0 +1 @@
+libASICamera2.so.1.13.0930 \ No newline at end of file
diff --git a/lib/x86/libASICamera2.so.1.13.0930 b/lib/x86/libASICamera2.so.1.13.0930
new file mode 100755
index 0000000..9338ca6
--- /dev/null
+++ b/lib/x86/libASICamera2.so.1.13.0930
Binary files differ
diff --git a/src/asicam/ASICamera2.rs b/src/asicam/ASICamera2.rs
new file mode 100644
index 0000000..7d029db
--- /dev/null
+++ b/src/asicam/ASICamera2.rs
@@ -0,0 +1,945 @@
+/* automatically generated by rust-bindgen */
+use std::os;
+
+pub struct CameraHandle(i32);
+
+pub const CAMERA_ID_MAX: u32 = 128;
+#[repr(u32)]
+#[derive(Copy, Clone, Debug)]
+pub enum BayerPattern {
+ RG = 0,
+ BG = 1,
+ GR = 2,
+ GB = 3
+}
+
+#[repr(u32)]
+#[derive(Copy, Clone, Debug)]
+pub enum ImageType {
+ RAW8 = 0,
+ RGB24 = 1,
+ RAW16 = 2,
+ Y8 = 3,
+ END = 0xffffffff
+}
+/*
+pub const ASI_GUIDE_DIRECTION_ASI_GUIDE_NORTH: ASI_GUIDE_DIRECTION = 0;
+pub const ASI_GUIDE_DIRECTION_ASI_GUIDE_SOUTH: ASI_GUIDE_DIRECTION = 1;
+pub const ASI_GUIDE_DIRECTION_ASI_GUIDE_EAST: ASI_GUIDE_DIRECTION = 2;
+pub const ASI_GUIDE_DIRECTION_ASI_GUIDE_WEST: ASI_GUIDE_DIRECTION = 3;
+pub type ASI_GUIDE_DIRECTION = u32;
+*/
+#[repr(u32)]
+#[derive(Copy, Clone, Debug)]
+pub enum FlipStatus {
+ None = 0,
+ Horizontal = 1,
+ Vertical = 2,
+ Both = 3
+}
+
+#[repr(u32)]
+#[derive(Copy, Clone, Debug)]
+pub enum ErrorCode {
+ Success = 0,
+ InvalidIndex = 1,
+ InvalidId = 2,
+ InvalidControlType = 3,
+ CameraClosed = 4,
+ CameraRemoved = 5,
+ InvalidPath = 6,
+ InvalidFileformat = 7,
+ InvalidSize = 8,
+ InvalidImgtype = 9,
+ OutofBoundary = 10,
+ Timeout = 11,
+ InvalidSequence = 12,
+ BufferTooSmall = 13,
+ VideoModeActive = 14,
+ ExposureInProgress = 15,
+ GeneralError = 16,
+ InvalidMode = 17,
+ End = 18
+}
+
+#[repr(u32)]
+#[derive(Copy, Clone, Debug, PartialEq)]
+pub enum AsiBool {
+ False = 0,
+ True = 1
+}
+
+impl From<AsiBool> for bool {
+ fn from(asi_bool: AsiBool) -> Self {
+ match asi_bool {
+ AsiBool::False => false,
+ AsiBool::True => true
+ }
+ }
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct CameraInfo {
+ pub name: [os::raw::c_char; 64usize],
+ pub camera_id: os::raw::c_int,
+ pub max_height: os::raw::c_long,
+ pub max_width: os::raw::c_long,
+ pub is_color_cam: AsiBool,
+ pub bayer_pattern: BayerPattern,
+ pub supported_bins: [os::raw::c_int; 16usize ],
+ pub supported_video_format: [ImageType; 8usize ],
+ pub pixel_size: f64,
+ pub mechanical_shutter: AsiBool,
+ pub ST4_port: AsiBool,
+ pub is_cooler_cam: AsiBool,
+ pub is_USB3_host: AsiBool,
+ pub is_USB3_camera: AsiBool,
+ pub elec_per_ADU: f32,
+ pub bit_depth: os::raw::c_int,
+ pub is_trigger_cam: AsiBool,
+ pub unused: [os::raw::c_char; 16usize ]
+}
+
+#[repr(u32)]
+#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
+pub enum ControlType {
+ Gain = 0,
+ Exposure = 1,
+ Gamma = 2,
+ WB_R = 3,
+ WB_B = 4,
+ Offset = 5,
+ BandwidthOverload = 6,
+ Overclock = 7,
+ Temperature = 8,
+ Flip = 9,
+ AutoMaxGain = 10,
+ AutoMaxExp = 11,
+ AutoTargetBrightness = 12,
+ HardwareBin = 13,
+ HighSpeedMode = 14,
+ CoolerPowerPerc = 15,
+ TargetTemp = 16,
+ CoolerOn = 17,
+ MonoBin = 18,
+ FanOn = 19,
+ PatternAdjust = 20,
+ AntiDewHeater = 21
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct ControlCaps {
+ pub name: [os::raw::c_char; 64usize ],
+ pub description: [os::raw::c_char; 128usize ],
+ pub max_value: os::raw::c_long,
+ pub min_value: os::raw::c_long,
+ pub default_value: os::raw::c_long,
+ pub is_auto_supported: AsiBool,
+ pub is_writable: AsiBool,
+ pub control_type: ControlType,
+ pub Unused: [os::raw::c_char; 32usize ]
+}
+
+#[repr(u32)]
+#[derive(Copy, Clone, Debug)]
+pub enum ExposureStatus {
+ Idle = 0,
+ Working = 1,
+ Success = 2,
+ Failed = 3
+}
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct ID {
+ pub id: [os::raw::c_uchar; 8usize ]
+}
+
+extern "C" {
+ #[doc = "this should be the first API to be called"]
+ #[doc = "get number of connected ASI cameras"]
+ pub fn ASIGetNumOfConnectedCameras() -> os::raw::c_int;
+}
+extern "C" {
+#[doc = "get the product ID of each supported camera, at first set pPIDs as 0 and get length and then malloc a buffer to contain the PIDs"]
+#[doc = "Return: length of the array."]
+ pub fn ASIGetProductIDs(pPIDs: *mut os::raw::c_int) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "get the property of the connected cameras, you can do this without open the camera." ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_CAMERA_INFO *pASICameraInfo: Pointer to structure containing the property of camera" ]
+# [ doc = "user need to malloc the buffer" ]
+# [ doc = "int iCameraIndex: 0 means the first connect camera, 1 means the second connect camera" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS: Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_INDEX :no camera connected or index value out of boundary" ]
+ pub fn ASIGetCameraProperty(pASICameraInfo: *mut CameraInfo, iCameraIndex: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "open the camera before any operation to the camera, this will not affect the camera which is capturing" ]
+# [ doc = "All APIs below need to open the camera at first." ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS: Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_ID : no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_CAMERA_REMOVED: failed to find the camera, maybe camera has been removed" ]
+ pub fn ASIOpenCamera(iCameraID : os::raw::c_int) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions" ]
+# [ doc = "" ]
+# [ doc = "Initialise the camera after open, this function may take some while, this will affect the camera which is capturing" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIInitCamera (iCameraID: os::raw::c_int) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "you need to close the camera to free all the resource" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS :it will return success even the camera already closed" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASICloseCamera (iCameraID : os::raw::c_int) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get number of controls available for this camera. the camera need be opened at first." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int * piNumberOfControls: pointer to an int to save the number of controls" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetNumOfControls ( iCameraID: os::raw::c_int , piNumberOfControls : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get controls property available for this camera. the camera need be opened at first." ]
+# [ doc = "user need to malloc and maintain the buffer." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int iControlIndex: index of control, NOT control type" ]
+# [ doc = "ControlCaps * pControlCaps: Pointer to structure containing the property of the control" ]
+# [ doc = "user need to malloc the buffer" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetControlCaps ( iCameraID: os::raw::c_int , iControlIndex: os::raw::c_int , pControlCaps : * mut ControlCaps ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get controls property value and auto value" ]
+# [ doc = "note:the value of the temperature is the float value * 10 to convert it to long type, control name is \"Temperature\"" ]
+# [ doc = "because long is the only type for control(except cooler\'s target temperature, because it is an integer)" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int ControlType: this is get from control property use the API ASIGetControlCaps" ]
+# [ doc = "long *plValue: pointer to the value you want to save the value get from control" ]
+# [ doc = "AsiBool *pbAuto: pointer to the AsiBool type" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type" ]
+ pub fn ASIGetControlValue ( iCameraID: os::raw::c_int , ControlType: os::raw::c_int , plValue : * mut os::raw::c_long , pbAuto : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Set controls property value and auto value" ]
+# [ doc = "it will return success and set the max value or min value if the value is beyond the boundary" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int ControlType: this is get from control property use the API ASIGetControlCaps" ]
+# [ doc = "long lValue: the value set to the control" ]
+# [ doc = "AsiBool bAuto: set the control auto" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type" ]
+# [ doc = "ASI_ERROR_GENERAL_ERROR,//general error, eg: value is out of valid range; operate to camera hareware failed" ]
+ pub fn ASISetControlValue ( iCameraID: os::raw::c_int , ControlType: os::raw::c_int , lValue: os::raw::c_long , bAuto: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "set the ROI area before capture." ]
+# [ doc = "you must stop capture before call it." ]
+# [ doc = "the width and height is the value after binning." ]
+# [ doc = "ie. you need to set width to 640 and height to 480 if you want to run at 640X480@BIN2" ]
+# [ doc = "ASI120\'s data size must be times of 1024 which means width*height%1024=0" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int iWidth, the width of the ROI area. Make sure iWidth%8 = 0." ]
+# [ doc = "int iHeight, the height of the ROI area. Make sure iHeight%2 = 0," ]
+# [ doc = "further, for USB2.0 camera ASI120, please make sure that iWidth*iHeight%1024=0." ]
+# [ doc = "int iBin, binning method. bin1=1, bin2=2" ]
+# [ doc = "ASI_IMG_TYPE Img_type: the output format you want" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_SIZE, //wrong video format size" ]
+# [ doc = "ASI_ERROR_INVALID_IMGTYPE, //unsupported image format, make sure iWidth and iHeight and binning is set correct" ]
+ pub fn ASISetROIFormat ( iCameraID: os::raw::c_int , iWidth: os::raw::c_int , iHeight: os::raw::c_int , iBin: os::raw::c_int , Img_type: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Start camera exposure. the following 4 API is usually used when long exposure required" ]
+# [ doc = "start exposure and check the exposure status then get the data" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "AsiBool bIsDark: means dark frame if there is mechanical shutter on the camera. otherwise useless" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_VIDEO_MODE_ACTIVE: video mode is working, you need to stop video capture first" ]
+ pub fn ASIStartExposure ( iCameraID: os::raw::c_int , bIsDark: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "to cancel the long exposure which is on." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIStopExposure ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "to get the exposure status, work with ASIStartExposure." ]
+# [ doc = "you can read the data if get ASI_EXP_SUCCESS. or have to restart exposure again" ]
+# [ doc = "if get ASI_EXP_FAILED" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_EXPOSURE_STATUS *pExpStatus: the exposure status" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetExpStatus ( iCameraID: os::raw::c_int , pExpStatus : * mut ExposureStatus ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get data after exposure." ]
+# [ doc = "please make sure the buffer size is biger enough to hold one image" ]
+# [ doc = "otherwise the this API will crash" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "unsigned char* pBuffer, caller need to malloc the buffer, make sure the size is big enough" ]
+# [ doc = "the size in byte:" ]
+# [ doc = "8bit mono:width*height" ]
+# [ doc = "16bit mono:width*height*2" ]
+# [ doc = "RGB24:width*height*3" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_TIMEOUT: no image get and timeout" ]
+ pub fn ASIGetDataAfterExp ( iCameraID: os::raw::c_int , pBuffer : * mut os::raw::c_uchar , lBuffSize: os::raw::c_long ) -> ErrorCode;
+}
+/*
+# [ repr ( C ) ]
+# [ derive ( Debug , Copy , Clone ) ]
+ pub struct _ASI_SUPPORTED_MODE { pub SupportedCameraMode : [ ASI_CAMERA_MODE;
+16usize ] , }
+} pub type ASI_SUPPORTED_MODE = _ASI_SUPPORTED_MODE;
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "this should be the first API to be called" ]
+# [ doc = "get number of connected ASI cameras," ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}number of connected ASI cameras. 1 means 1 camera connected." ]
+ pub fn ASIGetNumOfConnectedCameras ( ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions:" ]
+# [ doc = "get the product ID of each supported camera, at first set pPIDs as 0 and get length and then malloc a buffer to contain the PIDs" ]
+# [ doc = "" ]
+# [ doc = "Paras:" ]
+# [ doc = "int* pPIDs: pointer to array of PIDs" ]
+# [ doc = "" ]
+# [ doc = "Return: length of the array." ]
+ pub fn ASIGetProductIDs ( pPIDs : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get the property of the connected cameras, you can do this without open the camera." ]
+# [ doc = "here is the sample code:" ]
+# [ doc = "" ]
+# [ doc = "int iNumofConnectCameras = ASIGetNumOfConnectedCameras();" ]
+# [ doc = "ASI_CAMERA_INFO **ppASICameraInfo = (ASI_CAMERA_INFO **)malloc(sizeof(ASI_CAMERA_INFO *)*iNumofConnectCameras);" ]
+# [ doc = "for(int i = 0; i < iNumofConnectCameras; i++)" ]
+# [ doc = "{" ]
+# [ doc = "ppASICameraInfo[i] = (ASI_CAMERA_INFO *)malloc(sizeof(ASI_CAMERA_INFO ));" ]
+# [ doc = "ASIGetCameraProperty(ppASICameraInfo[i], i);" ]
+# [ doc = "}" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_CAMERA_INFO *pASICameraInfo: Pointer to structure containing the property of camera" ]
+# [ doc = "user need to malloc the buffer" ]
+# [ doc = "int iCameraIndex: 0 means the first connect camera, 1 means the second connect camera" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS: Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_INDEX :no camera connected or index value out of boundary" ]
+ pub fn ASIGetCameraProperty ( pASICameraInfo : * mut ASI_CAMERA_INFO , iCameraIndex: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "open the camera before any operation to the camera, this will not affect the camera which is capturing" ]
+# [ doc = "All APIs below need to open the camera at first." ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS: Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_ID : no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_CAMERA_REMOVED: failed to find the camera, maybe camera has been removed" ]
+ pub fn ASIOpenCamera ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions" ]
+# [ doc = "" ]
+# [ doc = "Initialise the camera after open, this function may take some while, this will affect the camera which is capturing" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIInitCamera ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "you need to close the camera to free all the resource" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS :it will return success even the camera already closed" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASICloseCamera ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get number of controls available for this camera. the camera need be opened at first." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int * piNumberOfControls: pointer to an int to save the number of controls" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetNumOfControls ( iCameraID: os::raw::c_int , piNumberOfControls : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get controls property available for this camera. the camera need be opened at first." ]
+# [ doc = "user need to malloc and maintain the buffer." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int iControlIndex: index of control, NOT control type" ]
+# [ doc = "ControlCaps * pControlCaps: Pointer to structure containing the property of the control" ]
+# [ doc = "user need to malloc the buffer" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetControlCaps ( iCameraID: os::raw::c_int , iControlIndex: os::raw::c_int , pControlCaps : * mut ControlCaps ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get controls property value and auto value" ]
+# [ doc = "note:the value of the temperature is the float value * 10 to convert it to long type, control name is \"Temperature\"" ]
+# [ doc = "because long is the only type for control(except cooler\'s target temperature, because it is an integer)" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int ControlType: this is get from control property use the API ASIGetControlCaps" ]
+# [ doc = "long *plValue: pointer to the value you want to save the value get from control" ]
+# [ doc = "AsiBool *pbAuto: pointer to the AsiBool type" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type" ]
+ pub fn ASIGetControlValue ( iCameraID: os::raw::c_int , ControlType: os::raw::c_int , plValue : * mut os::raw::c_long , pbAuto : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Set controls property value and auto value" ]
+# [ doc = "it will return success and set the max value or min value if the value is beyond the boundary" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int ControlType: this is get from control property use the API ASIGetControlCaps" ]
+# [ doc = "long lValue: the value set to the control" ]
+# [ doc = "AsiBool bAuto: set the control auto" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_CONTROL_TYPE, //invalid Control type" ]
+# [ doc = "ASI_ERROR_GENERAL_ERROR,//general error, eg: value is out of valid range; operate to camera hareware failed" ]
+ pub fn ASISetControlValue ( iCameraID: os::raw::c_int , ControlType: os::raw::c_int , lValue: os::raw::c_long , bAuto: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "set the ROI area before capture." ]
+# [ doc = "you must stop capture before call it." ]
+# [ doc = "the width and height is the value after binning." ]
+# [ doc = "ie. you need to set width to 640 and height to 480 if you want to run at 640X480@BIN2" ]
+# [ doc = "ASI120\'s data size must be times of 1024 which means width*height%1024=0" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int iWidth, the width of the ROI area. Make sure iWidth%8 = 0." ]
+# [ doc = "int iHeight, the height of the ROI area. Make sure iHeight%2 = 0," ]
+# [ doc = "further, for USB2.0 camera ASI120, please make sure that iWidth*iHeight%1024=0." ]
+# [ doc = "int iBin, binning method. bin1=1, bin2=2" ]
+# [ doc = "ASI_IMG_TYPE Img_type: the output format you want" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_INVALID_SIZE, //wrong video format size" ]
+# [ doc = "ASI_ERROR_INVALID_IMGTYPE, //unsupported image format, make sure iWidth and iHeight and binning is set correct" ]
+ pub fn ASISetROIFormat ( iCameraID: os::raw::c_int , iWidth: os::raw::c_int , iHeight: os::raw::c_int , iBin: os::raw::c_int , Img_type: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get the current ROI area setting ." ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int *piWidth, pointer to the width of the ROI area" ]
+# [ doc = "int *piHeight, pointer to the height of the ROI area." ]
+# [ doc = "int *piBin, pointer to binning method. bin1=1, bin2=2" ]
+# [ doc = "ASI_IMG_TYPE *pImg_type: pointer to the output format" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetROIFormat ( iCameraID: os::raw::c_int , piWidth : * mut os::raw::c_int , piHeight : * mut os::raw::c_int , piBin : * mut os::raw::c_int , pImg_type : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Set the start position of the ROI area." ]
+# [ doc = "you can call this API to move the ROI area when video is streaming" ]
+# [ doc = "the camera will set the ROI area to the center of the full image as default" ]
+# [ doc = "at bin2 or bin3 mode, the position is relative to the image after binning" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int iStartX, pointer to the start X" ]
+# [ doc = "int iStartY pointer to the start Y" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_OUTOF_BOUNDARY: the start x and start y make the image out of boundary" ]
+ pub fn ASISetStartPos ( iCameraID: os::raw::c_int , iStartX: os::raw::c_int , iStartY: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get the start position of current ROI area ." ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int *piStartX, pointer to the start X" ]
+# [ doc = "int *piStartY pointer to the start Y" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetStartPos ( iCameraID: os::raw::c_int , piStartX : * mut os::raw::c_int , piStartY : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Get the droped frames ." ]
+# [ doc = "drop frames happen when USB is traffic or harddisk write speed is slow" ]
+# [ doc = "it will reset to 0 after stop capture" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "int *piDropFrames pointer to drop frames" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetDroppedFrames ( iCameraID: os::raw::c_int , piDropFrames : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "provide a dark file\'s path to the function and enable dark subtract" ]
+# [ doc = "this is used when there is hot pixel or need to do long exposure" ]
+# [ doc = "you\'d better make this dark file from the \"dark subtract\" funtion" ]
+# [ doc = "of the \"video capture filter\" directshow page." ]
+# [ doc = "the dark file\'s size should be the same of camera\'s max width and height" ]
+# [ doc = "and should be RGB8 raw format.it will on even you changed the ROI setting" ]
+# [ doc = "it only correct the hot pixels if out put isn\'t 16bit." ]
+# [ doc = "" ]
+# [ doc = "it will be remembered in registry. so \"Dark subtract\" is on next time if you close your app." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "char *pcBMPPath: the path to the bmp dark file." ]
+# [ doc = "return\u{fffd}\u{fffd}" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_PATH, //cannot find the path of the file" ]
+# [ doc = "ASI_ERROR_INVALID_FILEFORMAT, //the dark file\'s size should be the same of camera\'s max width and height" ]
+ pub fn ASIEnableDarkSubtract ( iCameraID: os::raw::c_int , pcBMPPath : * mut os::raw::c_char ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Disable the dark subtract function." ]
+# [ doc = "you\'d better call it at start if you don\'t want to use it." ]
+# [ doc = "because dark subtract function is remembered on windows platform" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+ pub fn ASIDisableDarkSubtract ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Start video capture" ]
+# [ doc = "then you can get the data from the API ASIGetVideoData" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful, it will return success if already started" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_EXPOSURE_IN_PROGRESS: snap mode is working, you need to stop snap first" ]
+ pub fn ASIStartVideoCapture ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Stop video capture" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful, it will return success if already stopped" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIStopVideoCapture ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get data from the video buffer.the buffer is very small" ]
+# [ doc = "you need to call this API as fast as possible, otherwise frame will be discarded" ]
+# [ doc = "so the best way is maintain one buffer loop and call this API in a loop" ]
+# [ doc = "please make sure the buffer size is biger enough to hold one image" ]
+# [ doc = "otherwise the this API will crash" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "unsigned char* pBuffer, caller need to malloc the buffer, make sure the size is big enough" ]
+# [ doc = "the size in byte:" ]
+# [ doc = "8bit mono:width*height" ]
+# [ doc = "16bit mono:width*height*2" ]
+# [ doc = "RGB24:width*height*3" ]
+# [ doc = "" ]
+# [ doc = "int iWaitms, this API will block and wait iWaitms to get one image. the unit is ms" ]
+# [ doc = "-1 means wait forever. this value is recommend set to exposure*2+500ms" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_TIMEOUT: no image get and timeout" ]
+ pub fn ASIGetVideoData ( iCameraID: os::raw::c_int , pBuffer : * mut os::raw::c_uchar , lBuffSize: os::raw::c_long , iWaitms: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "PulseGuide of the ST4 port on. this function only work on the module which have ST4 port" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_GUIDE_DIRECTION direction the direction of guider" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIPulseGuideOn ( iCameraID: os::raw::c_int , direction: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "PulseGuide of the ST4 port off. this function only work on the module which have ST4 port" ]
+# [ doc = "make sure where is ASIPulseGuideOn and there is ASIPulseGuideOff" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_GUIDE_DIRECTION direction the direction of guider" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIPulseGuideOff ( iCameraID: os::raw::c_int , direction: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "Start camera exposure. the following 4 API is usually used when long exposure required" ]
+# [ doc = "start exposure and check the exposure status then get the data" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "AsiBool bIsDark: means dark frame if there is mechanical shutter on the camera. otherwise useless" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_VIDEO_MODE_ACTIVE: video mode is working, you need to stop video capture first" ]
+ pub fn ASIStartExposure ( iCameraID: os::raw::c_int , bIsDark: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "to cancel the long exposure which is on." ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIStopExposure ( iCameraID: os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "to get the exposure status, work with ASIStartExposure." ]
+# [ doc = "you can read the data if get ASI_EXP_SUCCESS. or have to restart exposure again" ]
+# [ doc = "if get ASI_EXP_FAILED" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_EXPOSURE_STATUS *pExpStatus: the exposure status" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetExpStatus ( iCameraID: os::raw::c_int , pExpStatus : * mut ASI_EXPOSURE_STATUS ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get data after exposure." ]
+# [ doc = "please make sure the buffer size is biger enough to hold one image" ]
+# [ doc = "otherwise the this API will crash" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "unsigned char* pBuffer, caller need to malloc the buffer, make sure the size is big enough" ]
+# [ doc = "the size in byte:" ]
+# [ doc = "8bit mono:width*height" ]
+# [ doc = "16bit mono:width*height*2" ]
+# [ doc = "RGB24:width*height*3" ]
+# [ doc = "" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+# [ doc = "ASI_ERROR_TIMEOUT: no image get and timeout" ]
+ pub fn ASIGetDataAfterExp ( iCameraID: os::raw::c_int , pBuffer : * mut os::raw::c_uchar , lBuffSize: os::raw::c_long ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get camera id stored in flash, only available for USB3.0 camera" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_ID* pID: pointer to ID" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetID ( iCameraID: os::raw::c_int , pID : * mut ASI_ID ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "write camera id to flash, only available for USB3.0 camera" ]
+# [ doc = "" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_ID ID: ID" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASISetID ( iCameraID: os::raw::c_int , ID : ASI_ID ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get pre-setting parameter" ]
+# [ doc = "Paras\u{fffd}\u{fffd}" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "Offset_HighestDR: offset at highest dynamic range," ]
+# [ doc = "Offset_UnityGain: offset at unity gain" ]
+# [ doc = "int *Gain_LowestRN, *Offset_LowestRN: gain and offset at lowest read noise" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetGainOffset ( iCameraID: os::raw::c_int , pOffset_HighestDR : * mut os::raw::c_int , pOffset_UnityGain : * mut os::raw::c_int , pGain_LowestRN : * mut os::raw::c_int , pOffset_LowestRN : * mut os::raw::c_int ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Descriptions\u{fffd}\u{fffd}" ]
+# [ doc = "get version string, like \"1, 13, 0503\"" ]
+ pub fn ASIGetSDKVersion ( ) -> * mut os::raw::c_char;
+}
+extern "C" {
+# [ doc = "Description:" ]
+# [ doc = "Get the camera supported mode, only need to call when the IsTriggerCam in the CameraInfo is true." ]
+# [ doc = "Paras:" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_SUPPORTED_MODE: the camera supported mode" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetCameraSupportMode ( iCameraID: os::raw::c_int , pSupportedMode : * mut ASI_SUPPORTED_MODE ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Description:" ]
+# [ doc = "Get the camera current mode, only need to call when the IsTriggerCam in the CameraInfo is true" ]
+# [ doc = "Paras:" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_CAMERA_MODE: the current camera mode" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_ID :no camera of this ID is connected or ID value is out of boundary" ]
+ pub fn ASIGetCameraMode ( iCameraID: os::raw::c_int , mode : * mut ASI_CAMERA_MODE ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Description:" ]
+# [ doc = "Set the camera mode, only need to call when the IsTriggerCam in the CameraInfo is true" ]
+# [ doc = "Paras:" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "ASI_CAMERA_MODE: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "" ]
+# [ doc = "return:" ]
+# [ doc = "ASI_SUCCESS : Operation is successful" ]
+# [ doc = "ASI_ERROR_CAMERA_CLOSED : camera didn\'t open" ]
+# [ doc = "ASI_ERROR_INVALID_SEQUENCE : camera is in capture now, need to stop capture first." ]
+# [ doc = "ASI_ERROR_INVALID_MODE : mode is out of boundary or this camera do not support this mode" ]
+ pub fn ASISetCameraMode ( iCameraID: os::raw::c_int , mode : ASI_CAMERA_MODE ) -> ErrorCode;
+}
+extern "C" {
+# [ doc = "Description:" ]
+# [ doc = "Send out a softTrigger. For edge trigger, it only need to set true which means send a" ]
+# [ doc = "rising trigger to start exposure. For level trigger, it need to set true first means" ]
+# [ doc = "start exposure, and set false means stop exposure.it only need to call when the" ]
+# [ doc = "IsTriggerCam in the CameraInfo is true" ]
+# [ doc = "Paras:" ]
+# [ doc = "int CameraID: this is get from the camera property use the API ASIGetCameraProperty" ]
+# [ doc = "AsiBool starts:send a softTrigger start/stop signal" ]
+ pub fn ASISendSoftTrigger ( iCameraID: os::raw::c_int , bStart: os::raw::c_int ) -> ErrorCode;
+}
+*/
diff --git a/src/asicam/mod.rs b/src/asicam/mod.rs
new file mode 100644
index 0000000..01b9ce7
--- /dev/null
+++ b/src/asicam/mod.rs
@@ -0,0 +1,282 @@
+pub mod ASICamera2;
+
+use self::ASICamera2::{CameraInfo, ControlCaps, ControlType, ExposureStatus, ImageType};
+
+use std::alloc::{alloc, dealloc, Layout};
+use std::collections::HashMap;
+use std::ffi::CStr;
+use std::os;
+use std::fs::File;
+use std::io::BufWriter;
+use std::path::Path;
+
+use png::HasParameters;
+
+#[derive(Debug)]
+pub struct Control {
+ pub name: String,
+ pub description: String,
+ pub max: i64,
+ pub min: i64,
+ pub default: i64,
+ pub can_auto: bool,
+ pub is_writable: bool,
+ pub control_type: ASICamera2::ControlType
+}
+
+#[derive(Debug)]
+pub struct Camera {
+ id: i32,
+ pub width: u32,
+ pub height: u32,
+ curr_width: u32,
+ curr_height: u32,
+ bin: u8,
+ color_format: ASICamera2::ImageType,
+ image_buffer: *mut u8,
+ controls: HashMap<ASICamera2::ControlType, Control>
+}
+
+impl Camera {
+ pub fn new(id: i32) -> Camera {
+ Camera {
+ id: id,
+ controls: HashMap::new(),
+ width: 0,
+ height: 0,
+ curr_width: 0,
+ curr_height: 0,
+ bin: 1,
+ image_buffer: std::ptr::null_mut(),
+ color_format: ASICamera2::ImageType::END
+ }
+ }
+
+ pub fn get_control_value(&self, control: ASICamera2::ControlType) -> Result<i64> {
+ let mut current: os::raw::c_long = 0;
+ let mut is_auto: os::raw::c_int = 0;
+ let res =
+ unsafe {
+ ASICamera2::ASIGetControlValue(
+ self.id,
+ control as i32,
+ &mut current as *mut os::raw::c_long,
+ &mut is_auto as *mut os::raw::c_int
+ )
+ };
+ build_result(current, res)
+ }
+
+ pub fn set_control_value(&mut self, control: ASICamera2::ControlType, value: i64) -> Result<()> {
+ let res =
+ unsafe {
+ ASICamera2::ASISetControlValue(
+ self.id,
+ control as i32,
+ value,
+ 0
+ )
+ };
+ build_result((), res)?;
+ match control {
+ ControlType::HardwareBin => {
+ if value == 0 {
+ self.curr_width *= 2;
+ self.curr_height *= 2;
+ Ok(())
+ } else if value == 1 {
+ self.curr_width /= 2;
+ self.curr_height /= 2;
+ Ok(())
+ } else {
+ // pretty sure this is unreachable,
+ // would be an out of band value and fail in `build_result`
+ unreachable!();
+ }
+ }
+ _ => Ok(())
+ }
+ }
+
+ pub fn set_exposure_ms(&mut self, ms: u64) -> Result<()> {
+ self.set_control_value(ControlType::Exposure, ms as i64 * 1000)
+ }
+
+ pub fn take_image(&self, path: &str) -> Result<()> {
+ let exposure_duration = self.get_control_value(ControlType::Exposure).unwrap();
+ let exposure_ms = exposure_duration / 1000;
+ unsafe {
+ let res = ASICamera2::ASIStartExposure(self.id, 0); // isDark == false, doesnt matter really
+ build_result((), res)?;
+ }
+
+ println!("Sleeping {}ms", exposure_ms + 2500);
+ std::thread::sleep(std::time::Duration::from_millis(exposure_ms as u64 + 2500));
+
+ let res = unsafe {
+ ASICamera2::ASIGetDataAfterExp(
+ self.id,
+ self.image_buffer,
+ self.curr_width as i64 * self.curr_height as i64 * 3
+ )
+ };
+ build_result((), res)?;
+
+ let dest = Path::new(path);
+ let file = File::create(dest).unwrap();
+ let ref mut w = BufWriter::new(file);
+ let mut encoder = png::Encoder::new(w, self.curr_width, self.curr_height);
+ encoder.set(png::ColorType::RGB).set(png::BitDepth::Eight);
+ let mut writer = encoder.write_header().unwrap();
+ writer.write_image_data(
+ unsafe {
+ std::slice::from_raw_parts(
+ self.image_buffer,
+ self.curr_width as usize * self.curr_height as usize* 3
+ )
+ }
+ ).unwrap();
+ Ok(())
+ }
+
+ pub fn exposure_status(&self) -> Result<ExposureStatus> {
+ let mut exposure_status = ExposureStatus::Failed;
+ let res = unsafe {
+ ASICamera2::ASIGetExpStatus(self.id, &mut exposure_status as *mut ExposureStatus)
+ };
+ build_result(exposure_status, res)
+ }
+
+ pub fn set_roi_format(&mut self, width: u32, height: u32, binning: u8, image_type: ImageType) -> Result<()> {
+ self.curr_width = width - (width % 8);
+ self.curr_height = height - (height % 8);
+ self.bin = binning;
+ let res = unsafe {
+ ASICamera2::ASISetROIFormat(
+ self.id,
+ self.curr_width as i32,
+ self.curr_height as i32,
+ self.bin as i32,
+ image_type as i32)
+ };
+ build_result((), res)
+ }
+}
+
+#[derive(Copy, Clone, Debug)]
+pub enum CameraError {
+ InvalidIndex = 1,
+ InvalidId = 2,
+ InvalidControlType = 3,
+ CameraClosed = 4,
+ CameraRemoved = 5,
+ InvalidPath = 6,
+ InvalidFileformat = 7,
+ InvalidSize = 8,
+ InvalidImgtype = 9,
+ OutofBoundary = 10,
+ Timeout = 11,
+ InvalidSequence = 12,
+ BufferTooSmall = 13,
+ VideoModeActive = 14,
+ ExposureInProgress = 15,
+ GeneralError = 16,
+ InvalidMode = 17,
+ End = 18
+}
+
+fn build_result<T>(value: T, err: ASICamera2::ErrorCode) -> Result<T> {
+ match err {
+ ASICamera2::ErrorCode::Success => { Ok(value) }
+ ASICamera2::ErrorCode::InvalidIndex => { Err(CameraError::InvalidIndex) }
+ ASICamera2::ErrorCode::InvalidId => { Err(CameraError::InvalidId) }
+ ASICamera2::ErrorCode::InvalidControlType => { Err(CameraError::InvalidControlType) }
+ ASICamera2::ErrorCode::CameraClosed => { Err(CameraError::CameraClosed) }
+ ASICamera2::ErrorCode::CameraRemoved => { Err(CameraError::CameraRemoved) }
+ ASICamera2::ErrorCode::InvalidPath => { Err(CameraError::InvalidPath) }
+ ASICamera2::ErrorCode::InvalidFileformat => { Err(CameraError::InvalidFileformat) }
+ ASICamera2::ErrorCode::InvalidSize => { Err(CameraError::InvalidSize) }
+ ASICamera2::ErrorCode::InvalidImgtype => { Err(CameraError::InvalidImgtype) }
+ ASICamera2::ErrorCode::OutofBoundary => { Err(CameraError::OutofBoundary) }
+ ASICamera2::ErrorCode::Timeout => { Err(CameraError::Timeout) }
+ ASICamera2::ErrorCode::InvalidSequence => { Err(CameraError::InvalidSequence) }
+ ASICamera2::ErrorCode::BufferTooSmall => { Err(CameraError::BufferTooSmall) }
+ ASICamera2::ErrorCode::VideoModeActive => { Err(CameraError::VideoModeActive) }
+ ASICamera2::ErrorCode::ExposureInProgress => { Err(CameraError::ExposureInProgress) }
+ ASICamera2::ErrorCode::GeneralError => { Err(CameraError::GeneralError) }
+ ASICamera2::ErrorCode::InvalidMode => { Err(CameraError::InvalidMode) }
+ ASICamera2::ErrorCode::End => { Err(CameraError::End) }
+ }
+}
+
+type Result<T> = std::result::Result<T, CameraError>;
+
+pub fn acquire(camera_id: i32) -> Result<Camera> {
+ unsafe {
+ let cameracount = ASICamera2::ASIGetNumOfConnectedCameras();
+ if camera_id >= cameracount {
+ panic!("Camera id is invalid (detected {} cameras)", camera_id);
+ }
+ let props_layout = Layout::array::<CameraInfo>(cameracount as usize).unwrap();
+ let props = alloc(props_layout) as *mut CameraInfo;
+ let res = ASICamera2::ASIGetCameraProperty(props, camera_id);
+ build_result((), res)?;
+ println!("Got properties");
+
+ let res = ASICamera2::ASIOpenCamera(camera_id);
+ build_result((), res)?;
+ println!("Opened camera");
+
+ let res = ASICamera2::ASIInitCamera(camera_id);
+ build_result((), res)?;
+ println!("Init'd camera");
+
+ let mut control_count: i32 = 0;
+ let res = ASICamera2::ASIGetNumOfControls(camera_id, &mut control_count as *mut os::raw::c_int);
+ build_result((), res)?;
+ println!("Got control count");
+
+ let control_layout = Layout::array::<ControlCaps>(1).unwrap();
+ let control = alloc(control_layout) as *mut ControlCaps;
+
+ let mut camera = Camera::new(camera_id);
+
+ let camera_props: CameraInfo = *props.offset(camera_id as isize);
+ camera.width = camera_props.max_width as u32;
+ camera.height = camera_props.max_height as u32;
+ camera.curr_width = camera_props.max_width as u32;
+ camera.curr_height = camera_props.max_height as u32;
+ camera.color_format = ImageType::RGB24;
+ camera.image_buffer = alloc(
+ Layout::from_size_align(camera.curr_width as usize * camera.curr_height as usize * 3, 8).unwrap()
+ );
+
+ let res = ASICamera2::ASISetROIFormat(camera_id, camera.width as i32, camera.height as i32, 1, ImageType::RGB24 as i32);
+ build_result((), res)?;
+ println!("Set ROI/Format");
+
+ for c in 0..control_count {
+ let res = ASICamera2::ASIGetControlCaps(0, c, control);
+ build_result((), res)?;
+ println!("Got control {:?}", c);
+
+ let control = Control {
+ name: CStr::from_ptr((*control).name.as_ptr()).to_str().unwrap().to_owned(),
+ description: CStr::from_ptr((*control).description.as_ptr()).to_str().unwrap().to_owned(),
+ max: (*control).max_value,
+ min: (*control).min_value,
+ default: (*control).default_value,
+ can_auto: bool::from((*control).is_auto_supported),
+ is_writable: bool::from((*control).is_writable),
+ control_type: (*control).control_type
+ };
+
+ camera.controls.insert(control.control_type, control);
+ }
+
+ dealloc(control as *mut u8, control_layout);
+ dealloc(props as *mut u8, props_layout);
+
+ Ok(camera)
+ }
+}
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..a9a664b
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,76 @@
+// use crate::ASICamera2::BayerPattern;
+//
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+#![allow(dead_code)]
+#![feature(alloc_layout_extra)]
+mod asicam;
+
+
+use crate::asicam::ASICamera2::{ControlType, ImageType};
+use crate::asicam::Camera;
+
+fn main() {
+ operate_qhy();
+}
+
+fn operate_qhy() {
+ println!("Operating on qhy camera ... or i'll die trying");
+}
+
+fn operate_asi() {
+ println!("Operating on asi camera ... or i'll die trying");
+ let mut camera = asicam::acquire(0).unwrap();
+
+ println!("{:?}", camera);
+ camera.set_control_value(ControlType::TargetTemp, -100).unwrap();
+ camera.set_control_value(ControlType::CoolerOn, 1).unwrap();
+ std::thread::sleep(std::time::Duration::from_millis(500));
+ println!("Camera temperature is currently {:?}", camera.get_control_value(ControlType::Temperature).unwrap());
+
+ /*
+ for exposure in [2000, 5000, 10000, 30000].iter() {
+ camera.set_control_value(ControlType::Exposure, *exposure).unwrap();
+ for gain in [450, 375, 325, 250, 200].iter() {
+ camera.set_control_value(ControlType::Gain, *gain).unwrap();
+ for offset in [100, 80, 60, 40, 20, 0].iter() {
+ camera.set_control_value(ControlType::Offset, *offset).unwrap();
+ take_calibration_images(&camera, 1, &format!("roof_gain_{:03}_offset_{:03}_exposure_{:06}", gain, offset, exposure));
+ }
+ }
+ }
+ */
+ camera.set_exposure_ms(45000).unwrap();
+// camera.set_control_value(ControlType::Exposure, 70000000).unwrap();
+ camera.set_control_value(ControlType::Gain, 350).unwrap();
+ camera.set_control_value(ControlType::Offset, 0).unwrap();
+ camera.set_control_value(ControlType::HardwareBin, 0).unwrap();
+ camera.set_roi_format(camera.width, camera.height, 1, ImageType::RGB24).unwrap();
+ take_calibration_images(&camera, 40, "dark_gain_350_exposure_45000");
+ /*
+ for exposure in [1000 * 1000 * 10].iter() {
+ camera.set_control_value(ControlType::Exposure, *exposure).unwrap();
+ for gain in [450, 375, 325, 250, 200].iter() {
+ camera.set_control_value(ControlType::Gain, *gain).unwrap();
+ for offset in [100, 80, 70, 60, 40, 0].iter() {
+ camera.set_control_value(ControlType::Offset, *offset).unwrap();
+ take_calibration_images(
+ &camera,
+ 30,
+ &format!("images/gain_{:03}_offset_{:03}_exposure_{:06}", gain, offset, exposure));
+ }
+ }
+ }
+ */
+
+ println!("Done!");
+}
+
+fn take_calibration_images(camera: &Camera, count: u32, path_fragment: &str) {
+ for i in 0..count {
+ println!("{} image {:06}", path_fragment, i);
+ let temp = camera.get_control_value(ControlType::Temperature).unwrap();
+ println!("Camera temperature is currently {:?}", temp);
+ camera.take_image(&format!("{}_{:06}_temp_{:03}.png", path_fragment, i, temp)).unwrap();
+ }
+}