Skip to content

Conversation

druzhkov-paul
Copy link

Pillow library is required for this script to run. To install it simply execute the following command in you terminal:
$ pip install Pillow

@zhiltsov-max
Copy link
Owner

@zhiltsov-max
Copy link
Owner

std::ifstream info("recognizer/data.txt");
if (info.is_open() == false) {
    std::cerr << "Failed to open file 'recognizer/data.txt'." << std::endl;
    return;
}

int i = 0;
int cat = 0;
cv::Mat img;
while (info.good() == true) {
    std::string img_name;
    std::string img_class_;
    std::getline(info, img_name, ' ');
    std::getline(info, img_class_);

    cv::Mat img = cv::imread(img_name);
    if (img.empty() == false) {
        data.push_back(img.reshape(0, 1));

        int img_class = std::atoi(img_class_.c_str());

        cv::Mat class_(1, classCount, CV_32S, cv::Scalar(0));
        if (0 <= img_class ) {
            class_.at<int>(img_class) = 1;
        }
        classes.push_back(class_);
    }
} while (img.empty() == false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants