/* AutoSize 2 The PictureBox is sized equal to the size of the image that it contains. CenterImage 3 The image is displayed in the center if the PictureBox is larger than the image. If the image is larger than the PictureBox, the picture is placed in the center of the PictureBox and the outside edges are clipped. Normal 0 The image is placed in the upper-left corner of the PictureBox. The image is clipped if it is larger than the PictureBox it is contained in. StretchImage 1 The image within the PictureBox is stretched or shrunk to fit the size of the PictureBox. Zoom 4 The size of the image is increased or decreased maintaining the size ratio. */ /* Public Enum eFLAG As Long FLAG_CMOS = &H1 ' cmos sensor FLAG_CCD_PROGRESSIVE = &H2 ' progressive ccd sensor FLAG_CCD_INTERLACED = &H4 ' interlaced ccd sensor FLAG_ROI_HARDWARE = &H8 ' support hardware ROI FLAG_MONO = &H10 ' monochromatic FLAG_BINSKIP_SUPPORTED = &H20 ' support bin/skip mode FLAG_USB30 = &H40 ' usb3.0 FLAG_TEC = &H80 ' Thermoelectric Cooler FLAG_USB30_OVER_USB20 = &H100 ' usb3.0 camera connected to usb2.0 port FLAG_ST4 = &H200 ' ST4 FLAG_GETTEMPERATURE = &H400 ' support to get the temperature of the sensor FLAG_PUTTEMPERATURE = &H800 ' support to put the target temperature of the sensor FLAG_RAW10 = &H1000 ' pixel format, RAW 10bits FLAG_RAW12 = &H2000 ' pixel format, RAW 12bits FLAG_RAW14 = &H4000 ' pixel format, RAW 14bits FLAG_RAW16 = &H8000 ' pixel format, RAW 16bits FLAG_FAN = &H10000 ' cooling fan FLAG_TEC_ONOFF = &H20000 ' Thermoelectric Cooler can be turn on or off, support to set the target temperature of TEC FLAG_ISP = &H40000 ' ISP (Image Signal Processing) chip FLAG_TRIGGER_SOFTWARE = &H80000 ' support software trigger FLAG_TRIGGER_EXTERNAL = &H100000 ' support external trigger FLAG_TRIGGER_SINGLE = &H200000 ' only support trigger single: one trigger, one image FLAG_BLACKLEVEL = &H400000 ' support set and get the black level FLAG_AUTO_FOCUS = &H800000 ' support auto focus FLAG_BUFFER = &H1000000 ' frame buffer FLAG_DDR = &H2000000 ' use very large capacity DDR (Double Data Rate SDRAM) for frame buffer FLAG_CG = &H4000000 ' Conversion Gain: HCG, LCG FLAG_YUV411 = &H8000000 ' pixel format, yuv411 FLAG_VUYY = &H10000000 ' pixel format, yuv422, VUYY FLAG_YUV444 = &H20000000 ' pixel format, yuv444 FLAG_RGB888 = &H40000000 ' pixel format, RGB888 FLAG_BITDEPTH10 = FLAG_RAW10 ' obsolete, same as FLAG_RAW10 FLAG_BITDEPTH12 = FLAG_RAW12 ' obsolete, same as FLAG_RAW12 FLAG_BITDEPTH14 = FLAG_RAW14 ' obsolete, same as FLAG_RAW14 FLAG_BITDEPTH16 = FLAG_RAW16 ' obsolete, same as FLAG_RAW16 FLAG_RAW8 = &H80000000 ' pixel format, RAW8 FLAG_GMCY8 = &H100000000 ' pixel format, GMCY8 FLAG_GMCY12 = &H200000000 ' pixel format, GMCY12 FLAG_UYVY = &H400000000 ' pixel format, yuv422, UYVY FLAG_CGHDR = &H800000000 ' Conversion Gain: HCG, LCG, HDR End Enum Public Enum eEVENT As UInteger EVENT_EXPOSURE = &H1 ' exposure time changed EVENT_TEMPTINT = &H2 ' white balance changed, Temp/Tint mode EVENT_CHROME = &H3 ' reversed, do not use it EVENT_IMAGE = &H4 ' live image arrived, use Toupcam_PullImage to get this image EVENT_STILLIMAGE = &H5 ' snap (still) frame arrived, use Toupcam_PullStillImage to get this frame EVENT_WBGAIN = &H6 ' white balance changed, RGB Gain mode EVENT_TRIGGERFAIL = &H7 ' trigger failed EVENT_BLACK = &H8 ' black balance EVENT_FFC = &H9 ' flat field correction status changed EVENT_DFC = &H9 ' dark field correction status changed EVENT_ERROR = &H80 ' generic error EVENT_DISCONNECTED = &H81 ' camera disconnected EVENT_TIMEOUT = &H82 ' timeout error EVENT_FACTORY = &H8001 ' restore factory settings End Enum Public Enum ePROCESSMODE As UInteger PROCESSMODE_FULL = &H0 ' better image quality, more cpu usage. this is the default value PROCESSMODE_FAST = &H1 ' lower image quality, less cpu usage End Enum Public Enum eOPTION As UInteger OPTION_NOFRAME_TIMEOUT = &H1 ' 1 = enable; 0 = disable. default: disable OPTION_THREAD_PRIORITY = &H2 ' set the priority of the internal thread which grab data from the usb device. iValue: 0 = THREAD_PRIORITY_NORMAL; 1 = THREAD_PRIORITY_ABOVE_NORMAL; 2 = THREAD_PRIORITY_HIGHEST; default: 0; see: msdn SetThreadPriority OPTION_PROCESSMODE = &H3 ' better image quality, more cpu usage. this is the default value ' 1 = lower image quality, less cpu usage OPTION_RAW = &H4 ' raw data mode, read the sensor "raw" data. This can be set only BEFORE Toupcam_StartXXX(). 0 = rgb, 1 = raw, default value: 0 OPTION_HISTOGRAM = &H5 ' 0 = only one, 1 = continue mode OPTION_BITDEPTH = &H6 ' 0 = 8 bits mode, 1 = 16 bits mode OPTION_FAN = &H7 ' 0 = turn off the cooling fan, [1, max] = fan speed OPTION_TEC = &H8 ' 0 = turn off the thermoelectric cooler, 1 = turn on the thermoelectric cooler OPTION_LINEAR = &H9 ' 0 = turn off the builtin linear tone mapping, 1 = turn on the builtin linear tone mapping, default value: 1 OPTION_CURVE = &Ha ' 0 = turn off the builtin curve tone mapping, 1 = turn on the builtin polynomial curve tone mapping, 2 = logarithmic curve tone mapping, default value: 2 OPTION_TRIGGER = &Hb ' 0 = video mode, 1 = software or simulated trigger mode, 2 = external trigger mode, default value = 0 OPTION_RGB = &Hc ' 0 => RGB24; 1 => enable RGB48 format when bitdepth > 8; 2 => RGB32; 3 => 8 Bits Gray (only for mono camera); 4 => 16 Bits Gray (only for mono camera when bitdepth > 8) OPTION_COLORMATIX = &Hd ' enable or disable the builtin color matrix, default value: 1 OPTION_WBGAIN = &He ' enable or disable the builtin white balance gain, default value: 1 OPTION_TECTARGET = &Hf ' get or set the target temperature of the thermoelectric cooler, in 0.1 degree Celsius. For example, 125 means 12.5 degree Celsius, -35 means -3.5 degree Celsius OPTION_AGAIN = &H10 ' enable or disable adjusting the analog gain when auto exposure is enabled. default value: enable OPTION_FRAMERATE = &H11 ' limit the frame rate, range=[0, 63], the default value 0 means no limit OPTION_DEMOSAIC = &H12 ' demosaic method for both video and still image: BILINEAR = 0, VNG(Variable Number of Gradients interpolation) = 1, PPG(Patterned Pixel Grouping interpolation) = 2, AHD(Adaptive Homogeneity-Directed interpolation) = 3, see https://en.wikipedia.org/wiki/Demosaicing, default value: 0 */ OPTION_DEMOSAIC_VIDEO = &H13 ' demosaic method for video OPTION_DEMOSAIC_STILL = &H14 ' demosaic method for still image OPTION_BLACKLEVEL = &H15 ' black level OPTION_MULTITHREAD = &H16 ' multithread image processing OPTION_BINNING = &H17 ' binning, 0x01 (no binning), 0x02 (add, 2*2), 0x03 (add, 3*3), 0x04 (add, 4*4), 0x82 (average, 2*2), 0x83 (average, 3*3), 0x84 (average, 4*4) OPTION_ROTATE = &H18 ' rotate clockwise: 0, 90, 180, 270 OPTION_CG = &H19 ' Conversion Gain: 0 = LCG, 1 = HCG, 2 = HDR OPTION_PIXEL_FORMAT = &H1a ' pixel format OPTION_FFC = &H1b ' flat field correction ' set: ' 0: disable ' 1: enable ' -1: reset ' (0xff000000 | n): average number, [1~255] ' get: ' (val & 0xff): 0 -> disable, 1 -> enable, 2 -> inited ' ((val & 0xff00) >> 8): sequence ' ((val & 0xff0000) >> 8): average number OPTION_DDR_DEPTH = &H1c ' the number of the frames that DDR can cache ' 1: DDR cache only one frame ' 0: Auto: ' ->one for video mode when auto exposure is enabled ' ->full capacity for others ' -1: DDR can cache frames to full capacity OPTION_DFC = &H1d ' dark field correction ' set: ' 0: disable ' 1: enable ' -1: reset ' (0xff000000 | n): average number, [1~255] ' get: ' (val & 0xff): 0 -> disable, 1 -> enable, 2 -> inited ' ((val & 0xff00) >> 8): sequence ' ((val & 0xff0000) >> 8): average number OPTION_SHARPENING = &H1e ' Sharpening: (threshold << 24) | (radius << 16) | strength) ' strength: [0, 500], default: 0 (disable) ' radius: [1, 10] ' threshold: [0, 255] ' OPTION_FACTORY = &H1f ' restore the factory settings OPTION_TEC_VOLTAGE = &H20 ' get the current TEC voltage in 0.1V, 59 mean 5.9V; readonly OPTION_TEC_VOLTAGE_MAX = &H21 ' get the TEC maximum voltage in 0.1V; readonly OPTION_DEVICE_RESET = &H22 ' reset usb device, simulate a replug End Enum Public Enum ePIXELFORMAT As Integer PIXELFORMAT_RAW8 = &H0 PIXELFORMAT_RAW10 = &H1 PIXELFORMAT_RAW12 = &H2 PIXELFORMAT_RAW14 = &H3 PIXELFORMAT_RAW16 = &H4 PIXELFORMAT_YUV411 = &H5 PIXELFORMAT_VUYY = &H6 PIXELFORMAT_YUV444 = &H7 PIXELFORMAT_RGB888 = &H8 PIXELFORMAT_GMCY8 = &H9 PIXELFORMAT_GMCY12 = &Ha PIXELFORMAT_UYVY = &Hb End Enum Public Enum eFRAMEINFO_FLAG As Integer FRAMEINFO_FLAG_SEQ = &H1 ' sequence number FRAMEINFO_FLAG_TIMESTAMP = &H2 End Enum Public Enum eIoControType As Integer IOCONTROTYPE_GET_SUPPORTEDMODE = &H1 ' 0x01->Input, 0x02->Output, (0x01 | 0x02)->support both Input and Output IOCONTROTYPE_GET_ALLSTATUS = &H2 ' A single bit field indicating the current logical state of all available line signals at time of polling IOCONTROTYPE_GET_MODE = &H3 ' 0x01->Input, 0x02->Output IOCONTROTYPE_SET_MODE = &H4 IOCONTROTYPE_GET_FORMAT = &H5 ' ' 0x00-> not connected ' 0x01-> Tri-state: Tri-state mode (Not driven) ' 0x02-> TTL: TTL level signals ' 0x03-> LVDS: LVDS level signals ' 0x04-> RS-422: RS-422 level signals ' 0x05-> Opto-coupled ' IOCONTROTYPE_SET_FORMAT = &H6 IOCONTROTYPE_GET_INVERTER = &H7 ' boolean IOCONTROTYPE_SET_INVERTER = &H8 IOCONTROTYPE_GET_LOGIC = &H9 ' 0x01->Positive, 0x02->Negative IOCONTROTYPE_SET_LOGIC = &Ha IOCONTROTYPE_GET_MINIMUMOUTPUTPULSEWIDTH = &Hb ' minimum signal width of an output signal (in microseconds) IOCONTROTYPE_SET_MINIMUMOUTPUTPULSEWIDTH = &Hc IOCONTROTYPE_GET_OVERLOADSTATUS = &Hd ' boolean IOCONTROTYPE_SET_OVERLOADSTATUS = &He IOCONTROTYPE_GET_PITCH = &Hf ' Number of bytes separating the starting pixels of two consecutive lines IOCONTROTYPE_SET_PITCH = &H10 IOCONTROTYPE_GET_PITCHENABLE = &H11 ' boolean IOCONTROTYPE_SET_PITCHENABLE = &H12 IOCONTROTYPE_GET_SOURCE = &H13 ' ' 0->ExposureActive ' 1->TimerActive ' 2->UserOutput ' 3->TriggerReady ' 4->SerialTx ' 5->AcquisitionTriggerReady IOCONTROTYPE_SET_SOURCE = &H14 IOCONTROTYPE_GET_STATUS = &H15 ' boolean IOCONTROTYPE_SET_STATUS = &H16 IOCONTROTYPE_GET_DEBOUNCERTIME = &H17 ' debouncer time in microseconds IOCONTROTYPE_SET_DEBOUNCERTIME = &H18 End Enum Public Const TEC_TARGET_MIN As Integer = -300 Public Const TEC_TARGET_DEF As Integer = -100 Public Const TEC_TARGET_MAX As Integer = 300 Public Const MAX_AE_EXPTIME As UInteger = 350000 ' default: 350 ms Public Const MAX_AE_AGAIN As UInteger = 500 Public Structure BITMAPINFOHEADER Public biSize As UInteger Public biWidth As Integer Public biHeight As Integer Public biPlanes As UShort Public biBitCount As UShort Public biCompression As UInteger Public biSizeImage As UInteger Public biXPelsPerMeter As Integer Public biYPelsPerMeter As Integer Public biClrUsed As UInteger Public biClrImportant As UInteger Public Sub Init() biSize = CUInt(Marshal.SizeOf(Me)) End Sub End Structure Public Structure Resolution Public width As UInteger Public height As UInteger End Structure Public Structure ModelV2 Public name As String Public flag As Long Public maxspeed As UInteger Public preview As UInteger Public still As UInteger Public maxfanspeed As UInteger Public ioctrol As UInteger Public xpixsz As Single Public ypixsz As Single Public res As Resolution() End Structure Public Structure InstanceV2 Public displayname As String Public id As String Public model As ModelV2 End Structure Public Structure FrameInfoV2 Public width As UInteger Public height As UInteger Public flag As UInteger ' FRAMEINFO_FLAG_xxxx Public seq As UInteger ' sequence number Public timestamp As ULong ' microsecond End Structure Public Structure Model Public name As String Public flag As UInteger Public maxspeed As UInteger Public preview As UInteger Public still As UInteger Public res As Resolution() End Structure Public Structure Instance Public displayname As String Public id As String Public model As Model End Structure ' ' soft trigger: ' nNumber: 0xffff: trigger continuously ' 0: cancel trigger ' others: number of images to be triggered ' Private Shared Function Toupcam_Trigger(h As SafeCamHandle, nNumber As UShort) As Integer End Function ' FourCC: ' MAKEFOURCC('G', 'B', 'R', 'G') ' MAKEFOURCC('R', 'G', 'G', 'B') ' MAKEFOURCC('B', 'G', 'G', 'R') ' MAKEFOURCC('G', 'R', 'B', 'G') ' MAKEFOURCC('Y', 'U', 'Y', 'V') ' MAKEFOURCC('Y', 'Y', 'Y', 'Y') Private Shared Function Toupcam_get_RawFormat(h As SafeCamHandle, ByRef nFourCC As UInteger, ByRef bitdepth As UInteger) As UInteger End Function ' ' ------------------------------------------------------------------| ' | Parameter | Range | Default | ' |-----------------------------------------------------------------| ' | Auto Exposure Target | 16~235 | 120 | ' | Temp | 2000~15000 | 6503 | ' | Tint | 200~2500 | 1000 | ' | LevelRange | 0~255 | Low = 0, High = 255 | ' | Contrast | -100~100 | 0 | ' | Hue | -180~180 | 0 | ' | Saturation | 0~255 | 128 | ' | Brightness | -64~64 | 0 | ' | Gamma | 20~180 | 100 | ' | WBGain | -127~127 | 0 | ' ------------------------------------------------------------------| ' Private Shared Function Toupcam_get_AutoExpoEnable(h As SafeCamHandle, ByRef bAutoExposure As Integer) As Integer End Function ' power supply: ' 0 -> 60HZ AC ' 1 -> 50Hz AC ' 2 -> DC ' Private Shared Function Toupcam_put_HZ(h As SafeCamHandle, nHZ As Integer) As Integer End Function ' ' S_FALSE: color mode ' S_OK: mono mode, such as EXCCD00300KMA and UHCCD01400KMA ' Private Shared Function Toupcam_get_MonoMode(h As SafeCamHandle) As Integer End Function ' ' ------------------------------------------------------------| ' | Parameter | Range | Default | ' |-----------------------------------------------------------| ' | VidgetAmount | -100~100 | 0 | ' | VignetMidPoint | 0~100 | 50 | ' ------------------------------------------------------------- ' Private Shared Function Toupcam_put_VignetEnable(h As SafeCamHandle, bEnable As Integer) As Integer End Function ' ' put_Size, put_eSize, can be used to set the video output resolution BEFORE Start. ' put_Size use width and height parameters, put_eSize use the index parameter. ' for example, UCMOS03100KPA support the following resolutions: ' index 0: 2048, 1536 ' index 1: 1024, 768 ' index 2: 680, 510 ' so, we can use put_Size(h, 1024, 768) or put_eSize(h, 1). Both have the same effect. ' Public Function put_Size(nWidth As Integer, nHeight As Integer) As Boolean If _handle Is Nothing OrElse _handle.IsInvalid OrElse _handle.IsClosed Then Return False End If Return (Toupcam_put_Size(_handle, nWidth, nHeight) >= 0) End Function */