|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include "opencv2/opencv.hpp"
#include <iostream>
// ...
STDMETHODIMP SampleCB(double Time, IMediaSample *pSample) {
if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0)
return S_OK;
HRESULT hr = pSample->GetPointer(&ptrBuffer);
if (hr == S_OK) {
latestBufferLength = pSample->GetActualDataLength();
if (latestBufferLength == numBytes) {
EnterCriticalSection(&critSection);
// 使用OpenCV进行缩放
cv::Mat frame(1080, 1920, CV_8UC3, ptrBuffer); // 创建输入帧
cv::Mat resizedFrame;
cv::resize(frame, resizedFrame, cv::Size(320, 240), 0, 0, cv::INTER_LINEAR); // 缩放到320*240
// 将缩放后的帧复制到pixels数组
memcpy(pixels, resizedFrame.data, resizedFrame.total() * resizedFrame.elemSize());
newFrame = true;
freezeCheck = 1;
LeaveCriticalSection(&critSection);
SetEvent(hEvent);
}
else {
printf("ERROR: SampleCB() - buffer sizes do not match\n");
}
}
// ...
}
resizedFrame.data的数组数据复制到pixels数组不正确,resizedFrame数据正常,复制到pixels数组的数据显示不正确求解? |
|