使用OpenCV从直线中提取点 我试图用C++中的OpenCV从图像中的直线上提取点。该线已编程显示在图像上,但我需要知道如何从该线提取点并将其输入文本文件?

使用OpenCV从直线中提取点 我试图用C++中的OpenCV从图像中的直线上提取点。该线已编程显示在图像上,但我需要知道如何从该线提取点并将其输入文本文件?,c++,opencv,C++,Opencv,您可以使用类获取光栅线的每个点,例如: // grabs pixels along the line (pt1, pt2) // from 8-bit 3-channel image to the buffer LineIterator it(img, pt1, pt2, 8); LineIterator it2 = it; vector<Vec3b> buf(it.count); for(int i = 0; i < it.count; i++, ++it) buf

您可以使用类获取光栅线的每个点,例如:

// grabs pixels along the line (pt1, pt2)
// from 8-bit 3-channel image to the buffer
LineIterator it(img, pt1, pt2, 8);
LineIterator it2 = it;
vector<Vec3b> buf(it.count);

for(int i = 0; i < it.count; i++, ++it)
    buf[i] = *(const Vec3b)*it;

// alternative way of iterating through the line
for(int i = 0; i < it2.count; i++, ++it2)
{
    Vec3b val = img.at<Vec3b>(it2.pos());
    CV_Assert(buf[i] == val);
}
//沿直线抓取像素(pt1、pt2)
//从8位3通道图像到缓冲区
行迭代器it(img、pt1、pt2、8);
LineIterator it2=它;
向量buf(it.count);
for(int i=0;i
您想检测线路,还是知道线路在哪里?您真的应该澄清您的问题。输入是什么?有线条的图像?您所说的“该行编程显示在图像上”是什么意思?