JPEG文件的尾部包含复杂的结构,例如:
FFD8...........................
...............................
............FFD9 1C01 0000 ....
...............................
struct definations in C file are:
typedef struct
{
short wYear;
short wMonth;
short wDayOfWeek;
short wDay;
short wHour;
short wMinute;
short wSecond;
short wMilliseconds;
}SYSEMTTIME;
typedef struct
{
int nOcrResult;
char szPlateText[16];
char szPlateColor[8];
char szCarColor[8];
RECT rtPlate;
} OCR_PLATE;
typedef struct
{
unsigned int size;
unsigned char nLane[4];
unsigned char nImageFalgs[4];
unsigned int nRandom[4];
unsigned char nIndex[4];
unsigned char nImageIndex[4];
unsigned char nTotalCount[4];
unsigned char nTrigerNow[4];
unsigned char nCarSpeed[4];
unsigned char nLimitSpeed[4];
unsigned char nDelayFrame[4];
OCR_PLATE struPlate[4];
SYSTEMTIME stTime;
unsigned int szFlags;
} IMAGE_CAPTURE_INFO;
在Python中,我使用ctype库编写了一些类:
class POINT(Structure):
_fields_ = [("x", c_int),("y", c_int)]
class RECT(Structure):
_fields_ = [("left", c_int),("top", c_int),("right", c_int),
("bottom", c_int)]
class OCR_PLATE(Structure):
_fields_ = [("nOcrResult", c_int),
("szPlateText", c_char * 16),
("szPlateColor", c_char * 8),
("szCarColor", c_char * 8),
("rtPlate", RECT)]
class SYSTEMTIME(Structure):
_fields_ = [("wYear", c_short),
("wMonth", c_short),
("wDayOfWeek", c_short),
("wDay", c_short),
("wHour", c_short),
("wMinute", c_short),
("wSecond", c_short),
("wMilliseconds", c_short)]
class IMAGE_CAPTURE_INFO(Structure):
_fields_ = [("size", c_uint),
("nLane", c_ubyte * 4),
("nImageFalgs", c_ubyte * 4),
("nRandom", c_uint * 4),
("nIndex", c_ubyte * 4),
("nImageIndex", c_ubyte * 4),
("nTotalCount", c_ubyte * 4),
("nTrigerNow", c_ubyte * 4),
("nCarSpeed", c_ubyte * 4),
("nLimitSpeed", c_ubyte * 4),
("nDelayFrame", c_ubyte * 4),
("struPlate", OCR_PLATE * 4),
("stTime", SYSTEMTIME),
("szFlags", c_uint)]
但是如何以上述结构的形式从JPEG图像文件中读取数据呢?你知道吗
您需要知道此结构在文件中的位置偏移量。
假设它位于文件末尾:
相关问题 更多 >
编程相关推荐