1 /** \file 2 * \brief Video Capture 3 * 4 * See Copyright Notice in im_lib.d 5 */ 6 7 module im.capture; 8 9 extern (C) @safe nothrow: 10 11 /** \defgroup capture Image Capture 12 * \par 13 * Functions to capture images from live video devices. 14 * \par 15 * See \ref im_capture.h 16 */ 17 18 /** \brief Video Capture Structure (Private). 19 * \ingroup capture */ 20 struct _imVideoCapture; 21 22 alias imVideoCapture = _imVideoCapture; 23 24 /** Returns the number of available devices. 25 * 26 * \verbatim im.VideoCaptureDeviceCount() -> count: number [in Lua 5] \endverbatim 27 * \ingroup capture */ 28 int imVideoCaptureDeviceCount(); 29 30 /** Returns the device description. Returns NULL only if it is an invalid device. 31 * 32 * \verbatim im.VideoCaptureDeviceDesc(device: number) -> desc: string [in Lua 5] \endverbatim 33 * \ingroup capture */ 34 const(char) * imVideoCaptureDeviceDesc(int device); 35 36 /** Returns the extendend device description. May return NULL. 37 * 38 * \verbatim im.VideoCaptureDeviceExDesc(device: number) -> desc: string [in Lua 5] \endverbatim 39 * \ingroup capture */ 40 const(char) * imVideoCaptureDeviceExDesc(int device); 41 42 /** Returns the device path configuration. This is a unique string. 43 * 44 * \verbatim im.VideoCaptureDevicePath(device: number) -> desc: string [in Lua 5] \endverbatim 45 * \ingroup capture */ 46 const(char) * imVideoCaptureDevicePath(int device); 47 48 /** Returns the vendor information. May return NULL. 49 * 50 * \verbatim im.VideoCaptureDeviceVendorInfo(device: number) -> desc: string [in Lua 5] \endverbatim 51 * \ingroup capture */ 52 const(char) * imVideoCaptureDeviceVendorInfo(int device); 53 54 /** Reload the device list. The devices can be dynamically removed or added to the system. 55 * Returns the number of available devices. 56 * 57 * \verbatim im.imVideoCaptureReloadDevices() -> count: number [in Lua 5] \endverbatim 58 * \ingroup capture */ 59 int imVideoCaptureReloadDevices(); 60 61 /** Release the device list. Usefull is you need to track leak erros in your application. 62 * 63 * \verbatim im.imVideoCaptureReleaseDevices() [in Lua 5] \endverbatim 64 * \ingroup capture */ 65 void imVideoCaptureReleaseDevices(); 66 67 /** Creates a new imVideoCapture object. \n 68 * Returns NULL if there is no capture device available. \n 69 * In Windows returns NULL if DirectX version is older than 8. \n 70 * In Lua the IM videocapture metatable name is "imVideoCapture". 71 * When converted to a string will return "imVideoCapture(%p)" where %p is replaced by the userdata address. 72 * If the videocapture is already destroyed by im.VideoCaptureDestroy, then it will return also the suffix "-destroyed". 73 * 74 * \verbatim im.VideoCaptureCreate() -> vc: imVideoCapture [in Lua 5] \endverbatim 75 * \ingroup capture */ 76 imVideoCapture* imVideoCaptureCreate(); 77 78 /** Destroys a imVideoCapture object. \n 79 * In Lua if this function is not called, the videocapture is destroyed by the garbage collector. 80 * 81 * \verbatim im.VideoCaptureDestroy(vc: imVideoCapture) [in Lua 5] \endverbatim 82 * \verbatim vc:Destroy() [in Lua 5] \endverbatim 83 * \ingroup capture */ 84 void imVideoCaptureDestroy(imVideoCapture* vc); 85 86 /** Connects to a capture device. 87 * More than one imVideoCapture object can be created 88 * but they must be connected to different devices. \n 89 * If the object is conected it will disconnect first. \n 90 * Use -1 to return the current connected device, 91 * in this case returns -1 if not connected. \n 92 * Returns zero if failed. 93 * 94 * \verbatim vc:Connect([device: number]) -> ret: number [in Lua 5] \endverbatim 95 * \ingroup capture */ 96 int imVideoCaptureConnect(imVideoCapture* vc, int device); 97 98 /** Disconnect from a capture device. 99 * 100 * \verbatim vc:Disconnect() [in Lua 5] \endverbatim 101 * \ingroup capture */ 102 void imVideoCaptureDisconnect(imVideoCapture* vc); 103 104 /** Returns the number of available configuration dialogs. 105 * 106 * \verbatim vc:DialogCount() -> count: number [in Lua 5] \endverbatim 107 * \ingroup capture */ 108 int imVideoCaptureDialogCount(imVideoCapture* vc); 109 110 /** Displays a configuration modal dialog of the connected device. \n 111 * In Windows, the capturing will be stopped in some cases. \n 112 * In Windows parent is a HWND of a parent window, it can be NULL. \n 113 * dialog can be from 0 to \ref imVideoCaptureDialogCount. \n 114 * Returns zero if failed. 115 * 116 * \verbatim vc:ShowDialog(dialog: number, parent: userdata) -> error: boolean [in Lua 5] \endverbatim 117 * \ingroup capture */ 118 int imVideoCaptureShowDialog(imVideoCapture* vc, int dialog, void* parent); 119 120 /** Returns the description of a configuration dialog. 121 * dialog can be from 0 to \ref imVideoCaptureDialogCount. \n 122 * 123 * \verbatim vc:DialogDesc(dialog: number) -> desc: string [in Lua 5] \endverbatim 124 * \ingroup capture */ 125 const(char) * imVideoCaptureDialogDesc(imVideoCapture* vc, int dialog); 126 127 /** Allows to control the input and output of devices that have multiple input and outputs. 128 * The cross index controls in which stage the input/output will be set. Usually use 1, but some capture boards 129 * has a second stage. In Direct X it controls the crossbars. 130 * 131 * \verbatim vc:SetInOut(input, output, cross: number) -> error: boolean [in Lua 5] \endverbatim 132 * \ingroup capture */ 133 int imVideoCaptureSetInOut(imVideoCapture* vc, int input, int output, int cross); 134 135 /** Returns the number of available video formats. \n 136 * Returns zero if failed. 137 * 138 * \verbatim vc:FormatCount() -> count: number [in Lua 5] \endverbatim 139 * \ingroup capture */ 140 int imVideoCaptureFormatCount(imVideoCapture* vc); 141 142 /** Returns information about the video format. \n 143 * format can be from 0 to \ref imVideoCaptureFormatCount. \n 144 * desc should be of size 10. \n 145 * The image size is usually the maximum size for that format. 146 * Other sizes can be available using \ref imVideoCaptureSetImageSize. \n 147 * Returns zero if failed. 148 * 149 * \verbatim vc:GetFormat(format: number) -> error: boolean, width: number, height: number, desc: string [in Lua 5] \endverbatim 150 * \ingroup capture */ 151 int imVideoCaptureGetFormat(imVideoCapture* vc, int format, int *width, int *height, char* desc); 152 153 /** Changes the video format of the connected device. \n 154 * Should NOT work for DV devices. Use \ref imVideoCaptureSetImageSize only. \n 155 * Use -1 to return the current format, in this case returns -1 if failed. \n 156 * When the format is changed in the dialog, for some formats 157 * the returned format is the preferred format, not the current format. \n 158 * This will not affect color_mode of the capture image. \n 159 * Returns zero if failed. 160 * 161 * \verbatim vc:SetFormat([format: number]) -> error: boolean | format: number [in Lua 5] \endverbatim 162 * \ingroup capture */ 163 int imVideoCaptureSetFormat(imVideoCapture* vc, int format); 164 165 /** Returns the current image size of the connected device. \n 166 * width and height returns 0 if not connected. 167 * 168 * \verbatim vc:GetImageSize() -> width: number, height: number [in Lua 5] \endverbatim 169 * \ingroup capture */ 170 void imVideoCaptureGetImageSize(imVideoCapture* vc, int *width, int *height); 171 172 /** Changes the image size of the connected device. \n 173 * Similar to \ref imVideoCaptureSetFormat, but changes only the size. \n 174 * Valid sizes can be obtained with \ref imVideoCaptureGetFormat. \n 175 * Returns zero if failed. 176 * 177 * \verbatim vc:SetImageSize(width: number, height: number) -> error: boolean [in Lua 5] \endverbatim 178 * \ingroup capture */ 179 int imVideoCaptureSetImageSize(imVideoCapture* vc, int width, int height); 180 181 /** Returns a new captured frame. Use -1 for infinite timeout. \n 182 * Color space can be IM_RGB or IM_GRAY, and mode can be packed (IM_PACKED) or not. \n 183 * Data type is always IM_BYTE. \n 184 * It can not have an alpha channel and orientation is always bottom up. \n 185 * Returns zero if failed or timeout expired, the buffer is not changed. 186 * 187 * \verbatim vc:Frame(image: imImage, timeout: number) -> error: boolean [in Lua 5] \endverbatim 188 * \ingroup capture */ 189 int imVideoCaptureFrame(imVideoCapture* vc, ubyte* data, int color_mode, int timeout); 190 191 /** Start capturing, returns the new captured frame and stop capturing. \n 192 * This is more usefull if you are switching between devices. \n 193 * Data format is the same as imVideoCaptureFrame. \n 194 * Returns zero if failed. 195 * 196 * \verbatim vc:OneFrame(image: imImage) -> error: boolean [in Lua 5] \endverbatim 197 * \ingroup capture */ 198 int imVideoCaptureOneFrame(imVideoCapture* vc, ubyte* data, int color_mode); 199 200 /** Start capturing. \n 201 * Use -1 to return the current state. \n 202 * Returns zero if failed. 203 * 204 * \verbatim vc:Live([live: number]) -> error: boolean | live: number [in Lua 5] \endverbatim 205 * \ingroup capture */ 206 int imVideoCaptureLive(imVideoCapture* vc, int live); 207 208 /** Resets a camera or video attribute to the default value or 209 * to the automatic setting. \n 210 * Not all attributes support automatic modes. \n 211 * Returns zero if failed. 212 * 213 * \verbatim vc:ResetAttribute(attrib: string, fauto: boolean) -> error: boolean [in Lua 5] \endverbatim 214 * \ingroup capture */ 215 int imVideoCaptureResetAttribute(imVideoCapture* vc, const(char) * attrib, int fauto); 216 217 /** Returns a camera or video attribute in percentage of the valid range value. \n 218 * Returns zero if failed or attribute not supported. 219 * 220 * \verbatim vc:GetAttribute(attrib: string) -> error: boolean, percent: number [in Lua 5] \endverbatim 221 * \ingroup capture */ 222 int imVideoCaptureGetAttribute(imVideoCapture* vc, const(char) * attrib, float *percent); 223 224 /** Changes a camera or video attribute in percentage of the valid range value. \n 225 * Returns zero if failed or attribute not supported. 226 * 227 * \verbatim vc:SetAttribute(attrib: string, percent: number) -> error: boolean [in Lua 5] \endverbatim 228 * \ingroup capture */ 229 int imVideoCaptureSetAttribute(imVideoCapture* vc, const(char) * attrib, float percent); 230 231 /** Returns a list of the description of the valid attributes for the device class. \n 232 * But each device may still not support some of the returned attributes. \n 233 * Use the return value of \ref imVideoCaptureGetAttribute to check if the attribute is supported. 234 * 235 * \verbatim vc:GetAttributeList() -> attrib_list: table of strings [in Lua 5] \endverbatim 236 * \ingroup capture */ 237 const(char) ** imVideoCaptureGetAttributeList(imVideoCapture* vc, int *num_attrib); 238 239 240 /** \defgroup winattrib Windows Attributes Names 241 * Not all attributes are supported by each device. 242 * Use the return value of \ref imVideoCaptureGetAttribute to check if the attribute is supported. 243 \verbatim 244 VideoBrightness - Specifies the brightness, also called the black level. 245 VideoContrast - Specifies the contrast, expressed as gain factor. 246 VideoHue - Specifies the hue angle. 247 VideoSaturation - Specifies the saturation. 248 VideoSharpness - Specifies the sharpness. 249 VideoGamma - Specifies the gamma. 250 VideoColorEnable - Specifies the color enable setting. (0/100) 251 VideoWhiteBalance - Specifies the white balance, as a color temperature in degrees Kelvin. 252 VideoBacklightCompensation - Specifies the backlight compensation setting. (0/100) 253 VideoGain - Specifies the gain adjustment. 254 CameraPanAngle - Specifies the camera's pan angle. To 100 rotate right, To 0 rotate left (view from above). 255 CameraTiltAngle - Specifies the camera's tilt angle. To 100 rotate up, To 0 rotate down. 256 CameraRollAngle - Specifies the camera's roll angle. To 100 rotate right, To 0 rotate left. 257 CameraLensZoom - Specifies the camera's zoom setting. 258 CameraExposure - Specifies the exposure setting. 259 CameraIris - Specifies the camera's iris setting. 260 CameraFocus - Specifies the camera's focus setting, as the distance to the optimally focused target. 261 FlipHorizontal - Specifies the video will be flipped in the horizontal direction. 262 FlipVertical - Specifies the video will be flipped in the vertical direction. 263 AnalogFormat - Specifies the video format standard NTSC, PAL, etc. Valid values: 264 NTSC_M = 0 265 NTSC_M_J = 1 266 NTSC_433 = 2 267 PAL_B = 3 268 PAL_D = 4 269 PAL_H = 5 270 PAL_I = 6 271 PAL_M = 7 272 PAL_N = 8 273 PAL_60 = 9 274 SECAM_B = 10 275 SECAM_D = 11 276 SECAM_G = 12 277 SECAM_H = 13 278 SECAM_K = 14 279 SECAM_K1 = 15 280 SECAM_L = 16 281 SECAM_L1 = 17 282 PAL_N_COMBO = 18 283 \endverbatim 284 * \ingroup capture */