【发布时间】:2015-02-16 07:42:54
【问题描述】:
我刚刚完成了 Udacity Parallel 编程第 2 阶段的课程,现在我正在使用 OpenCV 将我学到的知识应用到一个基本应用程序中,该应用程序将高斯模糊应用于来自网络摄像头的恒定图像流。
我正在将帧加载到Mat 对象中,而在我的循环中我想调用一个方法gaussian_cpu,唯一的问题是它需要将uchar4 传递给输入和输出参数。如何将Mat 对象转换为uchar4?
// Keep processing frames - Do CPU First
while(cpu_frames > 0)
{
cout << cpu_frames << "\n";
camera >> frameIn;
gaussian_cpu(frameIn, frameOut, numRows(), numCols(), h_filter__, 9);
imshow("Source", frameIn);
imshow("Dest", frameOut);
// 2ms delay to prevent system from being interrupted whilst drawing the new frame
waitKey(2);
cpu_frames--;
}
我的方法签名如下所示:
void gaussian_cpu(
const uchar4* const rgbaImage, // input image from the camera
uchar4* const outputImage, // The image we are writing back for display
size_t numRows, size_t numCols, // Width and Height of the input image (rows/cols)
const float* const filter, // The value of sigma
const int filterWidth // The size of the stencil (3x3) 9
)
我需要使用 uchar4 来拆分通道,进行卷积,然后重新组合通道以返回输出图像。有没有办法做到这一点?
【问题讨论】: