快照偵測的相關資料儲存在併入於快照偵測標題檔 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 資料結構含有一些值, 控制快照的哪些及多少代表框儲存在視訊型錄中。 有關這些值的使用說明,請參閱建置 storyboard。 定義資料結構的方法如下:
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 設定依視訊類型而定:
以 storyboard 而言,哪些及多少個代表框是最佳的,
依不同的視訊類型會有不同。
雖然預設的 DBvStoryboardCtrl 欄位設定較適合大部份視訊類型,
但您可能要在視訊的測試子集上使用這些設定。
然後,在為較寬的視訊設定建立 storyboard 之前,
您可以調整設定來符合您的需求。
欄位 | 意義 |
---|---|
thresh1 | 識別短快照的臨界值。
框數比 thresh1 值小的快照稱為短快照。
如果編目,則短快照的資訊將併入一個代表框 (指中間框) 中。
預設值是 90。如果 thresh1 值設定為 -1, 將快照將被視為一個短快照 (無論其實際長度)。 |
thresh2 | 識別中至大型快照的臨界值。
框數與 thresh2 值一樣或較小的快照,稱為中間快照。
如果編目,則中間快照的資訊將併入兩個代表框中。
代表框的位置由差異處(delta)欄位值控制。
框數比 thresh2 值大的快照稱為長快照。
如果編目,則長快照的資訊將併入三個代表框中。
第一個及最後一個代表框的位置由差異處(delta)欄位值控制。
第二個框是中間框。
預設值是 150。如果 thresh2 值設定為 -1, 則快照將被視為一個短快照 (無論其實際長度)。 |
delta | 識別代表框使用的偏移。
以中間和長快照而言,第一個代表框是藉由差異處的框數,從快照起始點偏移。
最後一個代表框是藉由差異處的框數,從快照結束點偏移。
預設值是 5。 |
DBvShotControl 資料結構中的值可控制快照偵測。 DBvStoryboardCtrl 資料結構中的值可控制 storyboard 的建置。 您可以為這些資料結構中的欄位明確指定一些值。 此外,您可以將這些結構中的值起始設定成預設值。 有關 DBvShotControl 資料結構中的預設值,請參閱表 10。 有關 DBvStoryboardCtrl 資料結構中的預設值,請參閱表 11。
使用 DBvInitShotControl API 來起始設定 DBvShotControl 資料結構中的值。 使用該 API 時,您必須指定快照控制結構。 例如,下列陳述式可將 DBvShotControl 結構中的欄位起始設定成預設值:
DBvShotControl shotCtrl; rc=DBvInitShotControl( shotCtrl); /* pointer to shot control structure */
使用 DBvInitStoryboardCtrl API 來起始設定 DBvStoryboardCtrl 資料結構中的值。 在使用該 API 時,您必須指定 storyboard 控制結構。 例如,下列陳述式可將 DBvStoryboardCtrl 結構中的欄位起始設定成預設值:
DBvStoryboardCtrl sbCtrl; rc=DBvInitStoryboardCtrl( sbCtrl); /* pointer to storyboard control structure */