Commit 8c1dfa89 张士柳

备份恢复

1 个父辈 3f8a946f
......@@ -88,7 +88,7 @@ int eyemVideoCapture(const char *fileName, IntPtr *hObject, EyemImage **tpImages
int totalFrmNum = cap.get(cv::CAP_PROP_FRAME_COUNT);
std::vector<cv::Mat> *pFrames = new std::vector<cv::Mat>();
std::vector<EyemImage> *pFrames = new std::vector<EyemImage>();
cv::Mat nextImg;
while (true)
......@@ -97,13 +97,79 @@ int eyemVideoCapture(const char *fileName, IntPtr *hObject, EyemImage **tpImages
if (nextImg.empty())
break;
//图像信息
EyemImage tpImage;
tpImage.iWidth = nextImg.cols; tpImage.iHeight = nextImg.rows; tpImage.iDepth = nextImg.depth(); tpImage.iChannels = nextImg.channels();
pFrames->push_back(nextImg);
//内存尺寸
int _Size = tpImage.iWidth*tpImage.iHeight*tpImage.iChannels;
//需要申请内存
switch (tpImage.iDepth)
{
case CV_8U:
_Size *= sizeof(uint8_t);
tpImage.vpImage = (uint8_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_8S:
_Size *= sizeof(int8_t);
tpImage.vpImage = (int8_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_16U:
_Size *= sizeof(uint16_t);
tpImage.vpImage = (uint16_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_16S:
_Size *= sizeof(int16_t);
tpImage.vpImage = (int16_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_32S:
_Size *= sizeof(int32_t);
tpImage.vpImage = (int32_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_32F:
_Size *= sizeof(float_t);
tpImage.vpImage = (float_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
case CV_64F:
_Size *= sizeof(double_t);
tpImage.vpImage = (double_t *)malloc(_Size);
if (NULL == tpImage.vpImage)
return FUNC_NOT_ENOUGH_MEM;
memset(tpImage.vpImage, 0, _Size);
break;
default:
//no support format
return FUNC_CANNOT_USE;
}
//拷贝数据
memcpy(tpImage.vpImage, nextImg.data, _Size);
//
pFrames->push_back(tpImage);
}
//*tpImages = pFrames->data();
//*ipNum = static_cast<int>(pFrames->size());
//*hObject = dynamic_cast<IntPtr>();
*tpImages = pFrames->data();
*ipNum = static_cast<int>(pFrames->size());
*hObject = reinterpret_cast<IntPtr>(pFrames);
return FUNC_OK;
}
......@@ -801,7 +867,14 @@ void eyemImageFree(EyemImage &tpImage)
int eyemVideoCaptureFree(IntPtr hObject)
{
std::vector<cv::Mat> *tpImages = reinterpret_cast<std::vector<cv::Mat>*>(hObject);
std::vector<EyemImage> *tpImages = reinterpret_cast<std::vector<EyemImage>*>(hObject);
for (std::vector<EyemImage>::iterator it = tpImages->begin(); it != tpImages->end(); ++it)
{
EyemImage tpImage = (*it);
tpImage.iWidth = tpImage.iHeight = tpImage.iDepth = tpImage.iChannels = 0;
free(tpImage.vpImage), tpImage.vpImage = NULL;
}
delete tpImages;
tpImages = NULL;
return true;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!