Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

reshape problem while training

I want to train my classifier LDA. I followed this link. but my code is crushing with memory exception and send me to this part of the code of reshape image description can't someone help me ?!

cv::Mat image1, flat_image;
    cv::Mat initial_image = cv::imread("D:\mémoire\DB\to use in training\images_sorted\\image1.jpg", 0);
    cv::Mat trainData = initial_image.reshape(1, 1);
    ////// trainData
    for (int i = 2; i < 30; i++)
    {
        std::string filename = "D:\mémoire\DB\to use in training\images_sorted\\image";
        filename = filename + std::to_string(i);
        filename = filename + ".jpg";
        image1 = cv::imread(filename, 0);
        flat_image = image1.reshape(1, 1);
        trainData.push_back(flat_image);
    }