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

Make2 #1

Merged
merged 11 commits into from
Jul 23, 2018
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.o
*~
core*
*.png
*.jpg
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compile all the source code (there is no executable!)
all:
$(MAKE) -C src

# Compile a sample C++ synthesizer program
sample:
$(MAKE) -C samples

# Prevent errors from occuring if a file were named 'clean'
.PHONY: clean

# Clean rule for getting rid of stray object files
clean:
rm -f bin/*.o *~ core* bin/*~ src/*~ samples/*.o samples/*~
159 changes: 78 additions & 81 deletions include/text/map_text_synthesizer.hpp
Original file line number Diff line number Diff line change
@@ -1,87 +1,84 @@
#ifndef MAP_TEXT_SYNTHESIZER_HPP
#define MAP_TEXT_SYNTHESIZER_HPP

#include <vector>
#include <memory>

#include <opencv2/opencv.hpp>
#include <opencv2/core/cvstd.hpp> // cv::String
#include <opencv2/core/types_c.h> // CV_EXPORTS_W
using namespace std;

namespace cv
{
namespace text
{
/*
* Class that renders synthetic text images for training a CNN
* on word recognition in historical maps
*/
class CV_EXPORTS_W MapTextSynthesizer{

protected:
/*
* Constructor.
*/
MapTextSynthesizer();

public:
/*
* Setter method to initialize the blockyFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setBlockyFonts (std::vector<String>& fntList) = 0;


/*
* Setter method to initialize the regularFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setRegularFonts (std::vector<String>& fntList) = 0;


/*
* Setter method to initialize the cursiveFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setCursiveFonts (std::vector<String>& fntList) = 0;


/*
* Set the collection of words to be displayed
*
* words - a list of strings to be sampled
*/
CV_WRAP virtual void
setSampleCaptions (std::vector<String>& words) = 0;


/*
* Generates a random bounded map-like text sample given a string
* This is the principal function of the text synthciser
*
* caption - the label of the image.
* sample - the resulting text sample.
*/
CV_WRAP virtual void
generateSample (CV_OUT String &caption, CV_OUT Mat& sample) = 0;

/*
* A wrapper for the protected MapTextSynthesizer constructor.
* Use this method to create a MTS object.
*/
CV_WRAP static Ptr<MapTextSynthesizer>
create ();


/*
* The destructor for the MapTextSynthesizer class
*/
virtual ~MapTextSynthesizer () {}
};
}//text
}//cv


/*
* Class that renders synthetic text images for training a CNN
* on word recognition in historical maps
*/
class CV_EXPORTS_W MapTextSynthesizer{

protected:
/*
* Constructor.
*/
MapTextSynthesizer();

public:
/*
* Setter method to initialize the blockyFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setBlockyFonts (std::vector<cv::String> &fntList) = 0;


/*
* Setter method to initialize the regularFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setRegularFonts (std::vector<cv::String> &fntList) = 0;


/*
* Setter method to initialize the cursiveFonts_ field
*
* fntList - a list of fonts contained in a vector
*/
CV_WRAP virtual void
setCursiveFonts (std::vector<cv::String> &fntList) = 0;


/*
* Set the collection of words to be displayed
*
* words - a list of strings to be sampled
*/
CV_WRAP virtual void
setSampleCaptions (std::vector<cv::String> &words) = 0;


/*
* Generates a random bounded map-like text sample given a string
* This is the principal function of the text synthciser
*
* caption - the label of the image.
* sample - the resulting text sample.
*/
CV_WRAP virtual void
generateSample (CV_OUT cv::String &caption, CV_OUT cv::Mat &sample) = 0;

/*
* A wrapper for the protected MapTextSynthesizer constructor.
* Use this method to create a MTS object.
*/
CV_WRAP static std::shared_ptr<MapTextSynthesizer>
create ();


/*
* The destructor for the MapTextSynthesizer class
*/
virtual ~MapTextSynthesizer () {}
};

#endif // MAP_TEXT_SYNTHESIZER_HPP
Loading