gpt4 book ai didi

c++ - 错误 : identifier undefined and is it possible to use at openCV

转载 作者:太空宇宙 更新时间:2023-11-03 22:26:32 27 4
gpt4 key购买 nike

考虑:

int cn = img_V.channels();
Scalar_<unit8_t> bgrPixel;

for (int i = 0; i < img_V.rows; i++)
{
uint8_t* rowPtr = img_V.row(i);
for (int j = 0; j < img_V.cols; j++)
{
bgrPixel.val[0] = rowPtr[j*cn + 0]; // B
bgrPixel.val[1] = rowPtr[j*cn + 1]; // G
bgrPixel.val[2] = rowPtr[j*cn + 2]; // R

// Do something with BGR values...
}
}

我正在使用 Visual Studio 和 OpenCV,但它无法识别显示错误的 uint8_t。我该如何解决这个问题?

最佳答案

你需要添加

#include <cstdint>

查看uint8_t

但是请注意,在 OpenCV 中您应该使用 uchar


另请注意,您没有正确循环播放。正确的做法是:

for (int i = 0; i < img_V.rows; i++)
{
Vec3b* rowPtr = img_V.ptr<Vec3b>(i);
for (int j = 0; j < img_V.cols; j++)
{
Vec3b& bgrPixel = rowPtr[j];

// Do something with BGR values...
}
}

关于c++ - 错误 : identifier <uint8_t> undefined and is it possible to use at openCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37027581/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com