与镜头检测相关的数据存储在镜头检测头文件 dmbshot.h 中包括的那些结构中。许多镜头检测 API 都要求您指向其中一个或多个结构。其中一些结构用来包含 Video Extender 用作输入的数据。例如,镜头控制结构包含控制镜头检测的信息。Video Extender 使用大多数结构来存储它从视频中检索到的数据。例如,视频帧数据结构包含帧的象素内容。
用于镜头检测的结构有 DBvIOType、DBvShotControl、DBvShotType、 DBvFrameData 和 DBvStoryboardCtrl。
DBvIOType 数据结构包含关于视频的数据,诸如它的格式、 尺寸和帧的数目。此数据结构定义如下:
typedef struct { FILE *hFile; /* file handle for the video */ char vhandle[255]; /* video handle (if from database) char vtable[255]; /* video table name (if from database) */ char vcolumn[255]; /* video column name (if from database) */ char vFile[255]; /* name of video file */ char idxFile[255]; /* name of index file */ char isIdx; /* 1 if the index exists, 0 otherwise */ char isInDb; /* 1 if from DB, 0 if from file */ int format; /* Format of the video */ unsigned long dx, dy; /* Dimensions of the video */ unsigned long totalFrames; /* TotalFrames in the video */ unsigned long markFrame; /* used by shot detection */ unsigned long currentFrame; /* The current video frame */ DBvFrameData fd; /* Frame data for current frame */ DBvDCFrameData fdDc; /* Frame data for DC images */ unsigned char BGRValid; /* reserved */ unsigned short usDeviceID; /* reserved */ unsigned long hwnd; /* reserved */ int videoReset; /* Flag if video is opened or seeked */ int firstshot; /* Used internally to indicate the first call */ void *reserved /* reserved */ } DBvIOType;
DBvShotControl 数据结构包含用来控制镜头检测的信息, 如检测方法。此数据结构定义如下:
typedef struct { unsigned long reserved; unsigned long method; /* detection method */ #define DETECT_CORRELATION 0x00000001 #define DETECT_HISTOGRAM 0x00000002 #define DETECT_CORRHIST 0x00000003 #define DETECT_CORRHISTDISS 0x00000004 int normalCorrValue; /* Correlation threshold */ int sceneCutSkipXY; /* reserved */ int CorrHistThresh; /* Histogram threshold */ int DissThresh; /* Dissolve threshold */ int DissCacheSize; /* Dissolve cache size */ int DissNumCaches; /* Dissolve cache number */ int minShotSize; /* Minimum frames in a shot */ } DBvShotControl;
下表描述了 DBvShotControl 中的每个字段及其允许的设置和缺省设置 要将这些字段初始化为缺省值, 按照初始化镜头检测数据结构中的值中的描述来使用 DBvInitShotControl API。
DBvShotControl 设置取决于视频的类型:
数字化视频中的画面切换随视频的内容和格式的不同而有很大变化。另外,画面切换算法的准确性随视频的不同而有所变化。与更细微类型的更改,或整体色彩内容保持不变的更改相比,
对整体帧外观有明显差异且清晰定义的画面切换的检测更准确。虽然对于大多数应用程序,缺省 DBvShotControl 字段设置就已足够,
但您可能需要调整这些设置以减少出错或未能检测的情况。
DBvShotType 数据结构包含关于镜头的信息, 诸如起始帧号、结束帧号和有代表性帧的号码; 以及指向有代表性帧的象素内容的指针。此数据结构定义如下:
typedef struct { unsigned long startFrame; /* starting frame number */ unsigned long endFrame; /* ending frame number */ unsigned long repFrame; /* representative frame number */ DBvFrameData fd; /* data for representative shot */ unsigned long dx; /* frame data width in pixels */ unsigned long dy; /* frame data height in pixels */ char *comment; /* shot remark */ } DBvShotType;
DBvFrameData 数据结构包含帧的象素内容。此数据结构定义如下:
typedef struct /* video frame data */ { /* MPEG 1 pixels */ unsigned char *luminance; /* Luminance pixel plane (black and white) */ unsigned char *Cr; /* Cr pixel plane */ unsigned char *Cb; /* Cb pixel plane */ unsigned char *reserved; } DBvFrameData;
DBvStoryboardCtrl 数据结构包含一些值, 用于控制将镜头中哪些以及多少有代表性帧存储在视频目录中。参见 构建故事板 以获取如何使用这些值的说明。此数据结构定义如下:
typedef struct { int thresh1; /* threshold for small to medium scenes */ int thresh2; /* threshold for medium to large scenes */ int delta; /* offset used for representative frames */ } DBvStoryboardCtrl;
下表描述了 DBvStoryboardCtrl 中的每个字段及其缺省设置。要将这些字段初始化为缺省值, 按照初始化镜头检测数据结构中的值 中的描述来使用 DBvInitStoryboardCtrl API。
DBvStoryboardCtrl 设置取决于视频的类型:视频的类型不同,
哪些以及多少有代表性帧对于故事板来说才最优可能有所变化。虽然对于许多类型的视频来说,缺省的 DBvStoryboardCtrl 类型设置工作得很好,
但您可能想使用这些设置来测试视频子集。然后,对这些设置进行适当调整,再为更大范围的一组视频构建故事板。
字段 | 含义 |
---|---|
thresh1 | 标识短镜头的阈值。所含帧数小于 thresh1 的值的镜头是短镜头。若已编目,
则短镜头的信息将包括一个有代表性帧(中间的帧)。
缺省值是 90。若将 thresh1 的值设置为 -1, 则将认为某个镜头是短镜头(不管它的实际长度是多少)。 |
thresh2 | 标识中镜头到大镜头的阈值。所含帧数等于或小于 thresh2的值,
但至少达到 thresh1 的值的镜头认为是中镜头。若已编目,则中镜头的信息将包括两个有代表性帧。有代表性帧的位置由 delta 字段的值控制。将所含帧数大于 thresh2 的值的镜头认为是长镜头。若已编目,则长镜头的信息将包括三个有代表性帧。第一个和最后一个有代表性帧的位置由 delta 字段的值控制。第二个帧是中间的帧。
缺省值是 150。若将 thresh2 的值设置为 -1, 则将认为某个镜头是短镜头(不管它的实际长度是多少)。 |
delta | 标识用于有代表性帧的位移。对于中等帧和长帧,第一个有代表性帧位于从镜头的开始算起,
经过 delta 中帧数的位移处。最后一个有代表性帧位于从帧的末尾算起,
经过 delta 中的帧数的位移处。
缺省值是 5。 |
DBvShotControl 数据结构中的值控制镜头检测。DBvStoryboardCtrl 数据结构中的值控制故事板的构建。可明确地为这些数据结构中的字段指定值。另外,还可以将这些结构中的值初始化为缺省值。参见表 10以获取 DBvShotControl 数据结构中的缺省值。参见表 11以获取 DBvStoryboardCtrl 数据结构中的缺省值。
使用 DBvInitShotControl API 来初始化 DBvShotControl 数据结构中的值。在使用此 API 时,需要指定镜头控制结构。例如,下列语句将 DBvShotControl 结构中的字段初始化为缺省值:
DBvShotControl shotCtrl; rc=DBvInitShotControl( shotCtrl); /* pointer to shot control structure */
使用 DBvInitStoryboardCtrl API 来初始化 DBvStoryboardCtrl 数据结构中的值。在使用此 API 时,需要指定故事板控制结构。例如,下列语句将 DBvStoryboardCtrl 结构中的字段初始化为缺省值:
DBvStoryboardCtrl sbCtrl; rc=DBvInitStoryboardCtrl( sbCtrl); /* pointer to storyboard control structure */