如何在Open CV(2.4.1)中创建'Point2f'对象矩阵

时间:2013-12-02 05:54:19

标签: c++ opencv

我正在尝试使用c ++ vector类在Open Cv(2.4.1)中创建一个Point2f对象矩阵。 这是我的代码:

vector<vector<Point> > trainingDescriptorMatrix;
    vector<Point> trainingDescriptor;



    //Search for white pixels from left to right,top to bottom. 
    for (i = 0 ; i < angle_binary.rows; i++){
        for (j = 0 ; j < angle_binary.cols; j++){

            if(angle_binary.at<bool>(i,j) != 0){ //White pixel found!!
                Point2f a(i,j);
                trainingDescriptor.push_back(a);
            }
        }

    trainingDescriptorMatrix.push_back(trainingDescriptor);
    trainingDescriptor.clear();
    }

    cout<<"trainingDescriptorMatrix size= "<<trainingDescriptorMatrix.size()<<endl;
    trainingDescriptor = trainingDescriptorMatrix[0];
    cout<<"trainingDescriptor size= "<<trainingDescriptor.size()<<endl;

代码行:

cout<<"trainingDescriptor size= "<<trainingDescriptor.size()<<endl;

输出:trainingDescriptor size = 0

看起来就像这一行:

trainingDescriptorMatrix.push_back(trainingDescriptor);

制作软拷贝然后当我擦除trainingDescriptor时,数据就消失了。

在Open CV(2.4.1)中制作'Point2f'对象矩阵的最简单方法是什么?

0 个答案:

没有答案