Example #1
0
void ChatHandler::sendRaw(const std::string &args) const
{
    std::string line = args;
    std::string str;
    MessageOut *outMsg = nullptr;

    if (line == "")
        return;

    size_t pos = line.find(" ");
    if (pos != std::string::npos)
    {
        str = line.substr(0, pos);
        outMsg = new MessageOut(static_cast<int16_t>(atoi(str.c_str())));
        line = line.substr(pos + 1);
        pos = line.find(" ");
    }
    else
    {
        outMsg = new MessageOut(static_cast<int16_t>(atoi(line.c_str())));
        delete outMsg;
        return;
    }

    while (pos != std::string::npos)
    {
        str = line.substr(0, pos);
        processRaw(*outMsg, str);
        line = line.substr(pos + 1);
        pos = line.find(" ");
    }
    if (line != "")
        processRaw(*outMsg, line);
    delete outMsg;
}
Example #2
0
void KisUnsharpFilter::processImpl(KisPaintDeviceSP device,
                                   const QRect& applyRect,
                                   const KisFilterConfiguration* config,
                                   KoUpdater* progressUpdater
                                   ) const
{

    QPointer<KoUpdater> filterUpdater = 0;
    QPointer<KoUpdater> convolutionUpdater = 0;
    KoProgressUpdater* updater = 0;

    if (progressUpdater) {
        updater = new KoProgressUpdater(progressUpdater);
        updater->start(100, i18n("Unsharp Mask"));
        // Two sub-sub tasks that each go from 0 to 100.
        convolutionUpdater = updater->startSubtask();
        filterUpdater = updater->startSubtask();
    }

    if (!config) config = new KisFilterConfiguration(id().id(), 1);

    QVariant value;

    KisLodTransformScalar t(device);

    const qreal halfSize = t.scale(config->getProperty("halfSize", value) ? value.toDouble() : 1.0);
    const qreal amount = (config->getProperty("amount", value)) ? value.toDouble() : 25;
    const uint threshold = (config->getProperty("threshold", value)) ? value.toUInt() : 0;
    const uint lightnessOnly = (config->getProperty("lightnessOnly", value)) ? value.toBool() : true;

    QBitArray channelFlags = config->channelFlags();
    KisGaussianKernel::applyGaussian(device, applyRect,
                                     halfSize, halfSize,
                                     channelFlags,
                                     progressUpdater);

    if (progressUpdater && progressUpdater->interrupted()) {
        return;
    }

    qreal weights[2];
    qreal factor = 128;

    weights[0] = factor * (1. + amount);
    weights[1] = -factor * amount;

    if (lightnessOnly) {
        processLightnessOnly(device, applyRect, threshold, weights, factor, channelFlags);
    } else {
        processRaw(device, applyRect, threshold, weights, factor, channelFlags);
    }

    delete updater;

    if (progressUpdater) progressUpdater->setProgress(100);
}
Example #3
0
int main(int argc, char *argv[]) {
    int go = 1;
    const char *lang    = argv[1];
    const char *rawFile = argv[2];
    cmd_ln_t *config;

    // Configure recognizer for English or Spanish
    if (strcmp(lang, "engl") == 0) {
        config = cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm",    MODELDIR "/en-us/en-us",
                "-lm",     MODELDIR "/en-us/en-us.lm.bin",
                "-dict",   MODELDIR "/en-us/cmudict-en-us.dict",
                NULL);

    } else if (strcmp(lang, "span") == 0) {
        config = cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm",     "/home/pi/es_MX_broadcast_cont_2500/model_parameters/hub4_spanish_itesm.cd_cont_2500",
                "-lm",      "/home/pi/es_MX_broadcast_cont_2500/etc/H4.arpa.Z.DMP",
                "-dict",    "/home/pi/es_MX_broadcast_cont_2500/etc/h4.dict",
                NULL);
    }

    if (config == NULL) {
        fprintf(stderr, "Failed to create config object, see log for details\n");
        return -1;
    }
    
    // Initialize pocketsphinx
    ps = ps_init(config);
    if (ps == NULL) {
        fprintf(stderr, "Failed to create recognizer, see log for details\n");
        return -1;
    }

    fflush(stdout);

    // Wait for signal from stdin
    while (1) {
        // Waiting for command
        scanf("%d", &go);
        if (go) {
            processRaw(rawFile);
        } else break;
    }

    // free memory
    ps_free(ps);
    cmd_ln_free_r(config);
    
    return 0;
}