Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a script for printing text to image #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add a script for printing text to image #2

wants to merge 1 commit into from

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