main.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  The MIT License (MIT)
00003 
00004  Copyright (c) <2013> <Vojtech Novak>
00005 
00006  Permission is hereby granted, free of charge, to any person obtaining a copy
00007  of this software and associated documentation files (the "Software"), to deal
00008  in the Software without restriction, including without limitation the rights
00009  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010  copies of the Software, and to permit persons to whom the Software is
00011  furnished to do so, subject to the following conditions:
00012 
00013  The above copyright notice and this permission notice shall be included in
00014  all copies or substantial portions of the Software.
00015 
00016  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022  THE SOFTWARE.
00023  *********************************************************************/
00024 
00025 #include "ros/ros.h"
00026 #include <message_filters/time_synchronizer.h>
00027 #include "TextLocator.hpp"
00028 
00029 using namespace ros;
00030 using namespace std;
00031 
00032 int main(int argc, char **argv) {
00033 
00034 //      ccv_swt_param_t example = { 1, 0.1, 0.8, //  NO BRACES!!!
00035 //                      1, 0, 2, //  size: parameters for Canny edge detector.
00036 //                      124, //  low_thresh: parameters for Canny edge detector.
00037 //                      204, //  high_thresh: parameters for Canny edge detector.
00038 //                      300, //  max_height: the maximum height for a letter.
00039 //                      3, //  min_height: the minimum height for a letter.
00040 //                      38, 3, 10, //  aspect_ratio: the maximum aspect ratio for a letter.
00041 //                      0.83, 2.5, //  thickness_ratio: the allowable thickness variance when grouping letters.
00042 //                      7.7, //  height_ratio: the allowable height variance when grouping letters.
00043 //                      31, //  intensity_thresh: the allowable intensity variance when grouping letters.
00044 //                      5, //  distance_ratio: the allowable distance variance when grouping letters.
00045 //                      1, //  intersect_ratio: the allowable intersect variance when grouping letters.
00046 //                      3, //  letter_thresh: the allowable letter threshold.
00047 //                      1, //  elongate_ratio: the allowable elongate variance when grouping letters.
00048 //                      0, //  breakdown: if breakdown text line into words.
00049 //                      1.0 //  breakdown_ratio: apply OSTU and if inter-class variance above the threshold,
00050 //                               //it will be break down into words.
00051 //                      };
00052 
00053         init(argc, argv, "text_locator_node");
00054         NodeHandle n;
00055         Rate r(3);
00056 
00057         vector<ccv_swt_param_t> params;
00058         params.push_back(ccv_swt_default_params);
00059         bool enableRecognition, enableDebug, enablePcl;
00060         param::param<bool>("enable_recognition", enableRecognition, true);
00061         param::param<bool>("enable_pcl", enablePcl, true);
00062         param::param<bool>("enable_param_debug", enableDebug, false);
00063 
00064         string lang, page_mode;
00065         param::param<std::string>("lang", lang, "eng");
00066         param::param<std::string>("page_mode", page_mode, "PSM_SINGLE_LINE");
00067 
00068         tesseract::PageSegMode pagesegmode;
00069         if (page_mode == "PSM_OSD_ONLY") {
00070                 pagesegmode = tesseract::PSM_OSD_ONLY;
00071         } else if (page_mode == "PSM_AUTO_OSD") {
00072                 pagesegmode = tesseract::PSM_AUTO_OSD;
00073         } else if (page_mode == "PSM_AUTO_ONLY") {
00074                 pagesegmode = tesseract::PSM_AUTO_ONLY;
00075         } else if (page_mode == "PSM_AUTO") {
00076                 pagesegmode = tesseract::PSM_AUTO;
00077         } else if (page_mode == "PSM_SINGLE_COLUMN") {
00078                 pagesegmode = tesseract::PSM_SINGLE_COLUMN;
00079         } else if (page_mode == "PSM_SINGLE_BLOCK_VERT_TEXT") {
00080                 pagesegmode = tesseract::PSM_SINGLE_BLOCK_VERT_TEXT;
00081         } else if (page_mode == "PSM_SINGLE_BLOCK") {
00082                 pagesegmode = tesseract::PSM_SINGLE_BLOCK;
00083         } else if (page_mode == "PSM_SINGLE_LINE") {
00084                 pagesegmode = tesseract::PSM_SINGLE_LINE;
00085         } else if (page_mode == "PSM_SINGLE_WORD") {
00086                 pagesegmode = tesseract::PSM_SINGLE_WORD;
00087         } else if (page_mode == "PSM_SINGLE_CHAR") {
00088                 pagesegmode = tesseract::PSM_SINGLE_CHAR;
00089         }
00090 
00091         ros_text_locator::TextLocator tl(n, pagesegmode, lang, params,
00092                         enableRecognition, enableDebug, enablePcl);
00093         tl.run();
00094 
00095         while (ros::ok())
00096         {
00097           ros::spinOnce();                   // Handle ROS events
00098           r.sleep();
00099         }
00100 
00101         return 0;
00102 }


text_locator
Author(s): Vojtech Novak
autogenerated on Mon Oct 6 2014 07:55:19