You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CNNRecognizer.cpp 615 B

7 years ago
12345678910111213141516171819
  1. //
  2. // Created by 庾金科 on 21/10/2017.
  3. //
  4. #include "CNNRecognizer.h"
  5. namespace pr{
  6. CNNRecognizer::CNNRecognizer(std::string prototxt,std::string caffemodel){
  7. net = cv::dnn::readNetFromCaffe(prototxt, caffemodel);
  8. }
  9. label CNNRecognizer::recognizeCharacter(cv::Mat charImage){
  10. if(charImage.channels()== 3)
  11. cv::cvtColor(charImage,charImage,cv::COLOR_BGR2GRAY);
  12. cv::Mat inputBlob = cv::dnn::blobFromImage(charImage, 1/255.0, cv::Size(CHAR_INPUT_W,CHAR_INPUT_H), cv::Scalar(0,0,0),false);
  13. net.setInput(inputBlob,"data");
  14. return net.forward();
  15. }
  16. }