DirectX 和 OpenCV
所以我已经编写了一个程序,可以将网络摄像头的图像捕获到名为 pBuffer 的向量中。 我可以轻松访问每个像素的 RGB 像素信息,只需通过
pBuffer[i]=R;pBuffer[i+1]=G;Buffer[i+2]=B。
这里没问题。
现在下一步是创建一个 IplImage* img,并用 pBuffer 的信息填充它......某种 SetPixel。
网络上有一个 SetPixel 函数,即:
(((uchar*)(image>imageData + image>widthStep*(y))))[x * image>nChannels + channel] = (uchar)value;
其中值是 pBuffer 信息,x 和 y 是像素坐标。但是我根本无法将其发挥作用。 有任何想法吗?? 我正在使用 C++。
So i have a program written already that captures the image from a webcam, into a vector called pBuffer.
I can easily acess the RGB pixel information of each pixel, simply by
pBuffer[i]=R;pBuffer[i+1]=G;Buffer[i+2]=B.
No problem in here.
The next step is now create an IplImage* img, and fill it in with the information of the pBuffer...some sort of SetPixel.
There is a SetPixel Function on the web, that is :
(((uchar*)(image>imageData + image>widthStep*(y))))[x * image>nChannels + channel] = (uchar)value;
where the value is the pBuffer information, x and y the pixel coordinates.However i simply cannot put this to work. Any ideas?? I am working with C++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要做的事情可以这样做(假设宽度和高度是图像尺寸):
但是,您不必复制数据。 您还可以通过 IplImage 使用图像数据(假设 pBuffer 是 char* 类型,否则您可能需要强制转换它):
What you are trying to do you can do like this (assuming width and height are the image dimensions):
However, you don't have to copy the data. You can also use your image data by IplImage (assuming pBuffer is of type char*, otherwise you need possibly to cast it):