/**************************************************
this is the second version of release ASI Camera ASIs
any question feel free contact us:software@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_TRIG_OUTPUT {
ASI_TRIG_OUTPUT_PINA = 0,//: Only Pin A output
ASI_TRIG_OUTPUT_PINB,//: Only Pin B output
ASI_TRIG_OUTPUT_NONE = -1
}ASI_TRIG_OUTPUT_PIN;
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 ASI_ID ASI_SN;
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:
get the property of the connected cameras by ID.
Paras:
ASI_CAMERA_INFO *pASICameraInfo: Pointer to structure containing the property of camera
user need to malloc the buffer
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 ASIGetCameraPropertyByID(int iCameraID, ASI_CAMERA_INFO *pASICameraInfo);
/***************************************************************************
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
Loading ...