<commit_before>//
//  pixFunc.cpp
//  ImageProcessing
//
//  Created by <NAME> on 19/02/2018.
//  Copyright © 2018 <NAME>. All rights reserved.
//

#include "pixFunc.hpp"
#include "PixBlurDetect.h"
#include "PixEdgeDetector.h"
#include "textsize.hpp"
#include "dewarp_textfairy.h"
#include "skew.h"
#include "savgol.hpp"
#include <cmath>

#ifdef HAS_ADAPTIVE_BINARIZER
#include "PixBinarizer.h"
#endif
#include "binarize.h"

#ifdef ANDROID
#include <android/log.h>

#define printf(fmt,args...)  __android_log_print(ANDROID_LOG_INFO  ,"pixFunc", fmt, ##args)
#define fprintf(file, fmt, args...)  __android_log_print(ANDROID_LOG_INFO  ,"pixFunc", fmt, ##args)
#define FUNCNAME(name)              PROCNAME(name)
#else
#define FUNCNAME(name)              procName = name
#endif





char const *procName = NULL;



Pix* convertTo8(Pix* pix) {
    FUNCNAME("convertTo8");
    return pixConvertTo8(pix, FALSE);
}

Pix* binarizeLegacy(Pix* pix){
    Pix* phm = NULL;
    Pix* pixb = binarizeTiled(pix, phm);
    pixCopyResolution(pixb, pix);
    return pixb;
    
}

#ifdef HAS_ADAPTIVE_BINARIZER
Pix* binarizeAdaptive(Pix* pix) {
    PixAdaptiveBinarizer binarizer(false);
    Pix* pixb =  binarizer.bradleyAdaptiveThresholding(pix, 0.11, 30);
    pixCopyResolution(pixb, pix);
    return pixb;
}
#endif

Pix* binarize(Pix* pix) {
    FUNCNAME("binarize");
    Pix *pixb;
#ifdef HAS_ADAPTIVE_BINARIZER
    PixBinarizer binarizer(false);
    pixb = binarizer.binarize(pix, NULL);
#else
    pixb = binarize(pix, NULL);
#endif
    pixCopyResolution(pixb, pix);
    return pixb;
}

Pix* binarize(Pix* pix, ProgressCallback* callback) {
    FUNCNAME("binarize");
    Pix *pixb;
#ifdef HAS_ADAPTIVE_BINARIZER
    PixBinarizer binarizer(false);
    pixb = binarizer.binarize(pix, callback);
#else
    pixb = binarize(pix, NULL);
#endif
    pixCopyResolution(pixb, pix);
    return pixb;
}

Pix* dewarpOrDeskew(Pix* pix) {
    FUNCNAME("dewarpOrDeskew");
    Pix* pixText = NULL;
    l_int32 dewarpResult = pixDewarp(pix, &pixText);
    
    if(dewarpResult){
        L_INFO("dewarp failed. Attempting to correct skew instead.", procName);
        pixText = deskew(pix);
    }
    pixCopyResolution(pixText, pix);
    return pixText;
}

Pix* timePixFunc(Pix* pix, PIX_FUNC pixFunc) {
    //PROCNAME("timePixFunc");
    L_TIMER totalTimer = startTimerNested();
    Pix* result = pixFunc(pix);
    l_float32 passedTime = stopTimerNested(totalTimer);
    L_INFO("func time %.2f\n", procName, passedTime);
    return result;
}
<commit_msg>fix: travis build<commit_after>//
//  pixFunc.cpp
//  ImageProcessing
//
//  Created by <NAME> on 19/02/2018.
//  Copyright © 2018 <NAME>. All rights reserved.
//

#include "pixFunc.hpp"
#include "PixBlurDetect.h"
#include "PixEdgeDetector.h"
#include "textsize.hpp"
#include "dewarp_textfairy.h"
#include "skew.h"
#include "savgol.hpp"
#include <cmath>

#ifdef HAS_ADAPTIVE_BINARIZER
#include "PixBinarizer.h"
#endif
#include "binarize.h"

#ifdef ANDROID
#include <android/log.h>

#define printf(fmt,args...)  __android_log_print(ANDROID_LOG_INFO  ,"pixFunc", fmt, ##args)
#define fprintf(file, fmt, args...)  __android_log_print(ANDROID_LOG_INFO  ,"pixFunc", fmt, ##args)
#define FUNCNAME(name)              PROCNAME(name)
#else
#define FUNCNAME(name)              procName = name
#endif





char const *procName = NULL;



Pix* convertTo8(Pix* pix) {
    FUNCNAME("convertTo8");
    return pixConvertTo8(pix, FALSE);
}

Pix* binarizeLegacy(Pix* pix){
    Pix* phm = NULL;
    Pix* pixb = binarizeTiled(pix, phm);
    pixCopyResolution(pixb, pix);
    return pixb;
    
}

#ifdef HAS_ADAPTIVE_BINARIZER
Pix* binarizeAdaptive(Pix* pix) {
    PixAdaptiveBinarizer binarizer(false);
    Pix* pixb =  binarizer.bradleyAdaptiveThresholding(pix, 0.11, 30);
    pixCopyResolution(pixb, pix);
    return pixb;
}
#endif

Pix* binarize(Pix* pix) {
    FUNCNAME("binarize");
    Pix *pixb;
#ifdef HAS_ADAPTIVE_BINARIZER
    PixBinarizer binarizer(false);
    pixb = binarizer.binarize(pix, NULL);
#else
    pixb = binarizeTiled(pix, NULL);
#endif
    pixCopyResolution(pixb, pix);
    return pixb;
}

Pix* binarize(Pix* pix, ProgressCallback* callback) {
    FUNCNAME("binarize");
    Pix *pixb;
#ifdef HAS_ADAPTIVE_BINARIZER
    PixBinarizer binarizer(false);
    pixb = binarizer.binarize(pix, callback);
#else
    pixb = binarizeTiled(pix, NULL);
#endif
    pixCopyResolution(pixb, pix);
    return pixb;
}

Pix* dewarpOrDeskew(Pix* pix) {
    FUNCNAME("dewarpOrDeskew");
    Pix* pixText = NULL;
    l_int32 dewarpResult = pixDewarp(pix, &pixText);
    
    if(dewarpResult){
        L_INFO("dewarp failed. Attempting to correct skew instead.", procName);
        pixText = deskew(pix);
    }
    pixCopyResolution(pixText, pix);
    return pixText;
}

Pix* timePixFunc(Pix* pix, PIX_FUNC pixFunc) {
    //PROCNAME("timePixFunc");
    L_TIMER totalTimer = startTimerNested();
    Pix* result = pixFunc(pix);
    l_float32 passedTime = stopTimerNested(totalTimer);
    L_INFO("func time %.2f\n", procName, passedTime);
    return result;
}

{'fraction_non_alphanumeric': 0.1319224683544304, 'fraction_numerical': 0.009889240506329115, 'mean_word_length': 3.943304007820137, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3630134', 'n_tokens_mistral': 2117, 'n_tokens_neox': 1912, 'n_words': 404}