cv::Mat CartoonProcessor::operator()(cv::Mat im) { cv::Mat grey; cv::cvtColor( im, grey, CV_BGR2GRAY ); // Get rid of speckle first by median filter const int MEDIAN_KERNEL_SIZE = 9; cv::medianBlur(grey, grey, MEDIAN_KERNEL_SIZE); cv::Mat gradX; cv::Scharr(grey, gradX, CV_32F, 1, 0); cv::Mat gradY; cv::Scharr(grey, gradY, CV_32F, 0, 1); cv::Mat gradient; cv::subtract( gradX, gradY, gradient); cv::convertScaleAbs(gradient, gradient); cv::Mat blurred; cv::blur(gradient, blurred, cv::Size(9,9)); cv::Mat thresh; cv::threshold(gradient, thresh, 150, 255, cv::THRESH_BINARY_INV ); // Display intermediate images for debugging cv::Mat dest; createOutput( thresh, dest ); return dest; /* cv::Mat segmented, gray, edges, edgesBgr; cv::pyrMeanShiftFiltering(im, segmented, 15, 40); cv::cvtColor(segmented, gray, CV_BGR2GRAY); cv::Canny(gray, edges, 150, 150); cv::cvtColor(edges, edgesBgr, CV_GRAY2BGR); cv::Mat result = segmented - edgesBgr; return result; */ }
const bool V3QuteRTLOutputHandler(V3NtkInput* const quteHandler, CktModule* const module, const bool& async2sync) { assert (quteHandler); assert (module); CktCell* cell; CktOutPin* OutPin; uint32_t width; string name; V3NetId id, id1; // Build Output (Renders the Same Order As Design Created by QuteRTL) V3BvNtk* const ntk = dynamic_cast<V3BvNtk*>(quteHandler->getNtk()); assert (ntk); for (uint32_t i = 0, j = quteGetDesignIoSize(module, QUTE_PO_CELL); i < j; ++i) { // Get Cell Info from QuteRTL cell = quteGetDesignIoCell(module, QUTE_PO_CELL, i); assert (cell); assert (quteGetCellOutputSize(cell) == 1); OutPin = quteGetCellOutputPin(cell, 0); assert (OutPin); name = quteGetOutPinName(OutPin); assert (name.size()); width = getOutPinWidthFromQuteRTL(name, OutPin); // Traverse PO Input assert (quteGetCellInputSize(cell) == 1); OutPin = quteGetCellInputPin(cell, 0); assert (OutPin); id1 = dfsBuildNtkFromQuteRTL(quteHandler, OutPin, async2sync); if (V3NetUD == id1) return false; // Build Output in V3 Ntk id = quteHandler->createNet(name, width); if (V3NetUD == id) return false; if ((id != id1) && (!createV3BufGate(ntk, id, id1))) return false; if (!createOutput(ntk, id)) return false; quteHandler->resetOutName(ntk->getOutputSize() - 1, name); } return true; }
int opensles_player_alloc(struct auplay_st **stp, struct auplay *ap, struct auplay_prm *prm, const char *device, auplay_write_h *wh, void *arg) { struct auplay_st *st; int err; (void)device; st = mem_zalloc(sizeof(*st), auplay_destructor); if (!st) return ENOMEM; st->ap = mem_ref(ap); st->wh = wh; st->arg = arg; err = createOutput(st); if (err) goto out; err = createPlayer(st, prm); if (err) goto out; bqPlayerCallback(st->BufferQueue, st); out: if (err) mem_deref(st); else *stp = st; return err; }
void RAMDirectory::_copyFromDir(Directory* dir, bool closeDir) { vector<string> names; dir->list(&names); uint8_t buf[CL_NS(store)::BufferedIndexOutput::BUFFER_SIZE]; for (size_t i=0;i<names.size();++i ){ if ( !CL_NS(index)::IndexReader::isLuceneFile(names[i].c_str())) continue; // make place on ram disk IndexOutput* os = createOutput(names[i].c_str()); // read current file IndexInput* is = dir->openInput(names[i].c_str()); // and copy to ram disk //todo: this could be a problem when copying from big indexes... int64_t len = is->length(); int64_t readCount = 0; while (readCount < len) { int32_t toRead = (int32_t)(readCount + CL_NS(store)::BufferedIndexOutput::BUFFER_SIZE > len ? len - readCount : CL_NS(store)::BufferedIndexOutput::BUFFER_SIZE); is->readBytes(buf, toRead); os->writeBytes(buf, toRead); readCount += toRead; } // graceful cleanup is->close(); _CLDELETE(is); os->close(); _CLDELETE(os); } if (closeDir) dir->close(); }
QWidget* createOutput(QWidget* parent) { parent->setObjectName("mixer"); QGridLayout* grid = new QGridLayout(parent); // row 1 grid->addWidget(createIndex("F1"), 0, 0); grid->addWidget(createOutput(new QGroupBox(), p_filter1_level, p_filter1_pan), 0, 1); // row 2 grid->addWidget(createIndex("F2"), 1, 0); grid->addWidget(createOutput(new QGroupBox(), p_filter2_level, p_filter2_pan), 1, 1); // row 3 grid->addWidget(createIndex("A"), 2, 0); grid->addWidget(createOutput(new QGroupBox(), p_bus_a_level, p_bus_a_pan), 2, 1); // row 4 grid->addWidget(createIndex("B"), 3, 0); grid->addWidget(createOutput(new QGroupBox(), p_bus_b_level, p_bus_b_pan), 3, 1); grid->setHorizontalSpacing(2); return parent; }
TAC_NODE* createOutput(TAC_NODE* code) { if(code==NULL) return code; int type; if(code->type == TAC_STRING) type = TAC_WRITE_STRING; else type = TAC_WRITE_VAR; return joinTacs(createTacNode(type, code->result, NULL, NULL), createOutput(code->next)); }
int opensles_player_alloc(struct auplay_st **stp, const struct auplay *ap, struct auplay_prm *prm, const char *device, auplay_write_h *wh, void *arg) { struct auplay_st *st; int err; (void)device; if (!stp || !ap || !prm || !wh) return EINVAL; debug("opensles: opening player %uHz, %uchannels\n", prm->srate, prm->ch); st = mem_zalloc(sizeof(*st), auplay_destructor); if (!st) return ENOMEM; st->ap = ap; st->wh = wh; st->arg = arg; st->sampc = prm->srate * prm->ch * PTIME / 1000; st->bufferId = 0; for (int i=0; i<N_PLAY_QUEUE_BUFFERS; i++) { st->sampv[i] = mem_zalloc(2 * st->sampc, NULL); if (!st->sampv[i]) { err = ENOMEM; goto out; } } err = createOutput(st); if (err) goto out; err = createPlayer(st, prm); if (err) goto out; /* kick-start the buffer callback */ bqPlayerCallback(st->BufferQueue, st); out: if (err) mem_deref(st); else *stp = st; return err; }
//Assumes input file doesn't have any errors. int main(int argc, char* argv[]){ milkSchedule sched; createShed(sched); std::pair<int,int> prevTime = sched.getNextTime(); //Used to find the longest farming time. int curLongBlock = prevTime.second - prevTime.first; int maxLongBlock = curLongBlock; //Used to find the longest non-farming time. int maxLongNonFarmBlock = 0; std::cout << prevTime.first << " " << prevTime.second << std::endl; int curLastFarmTime = prevTime.second;// Used to ensure when there's no farming happening. for(int i = 0; i < sched.getNumTimes() - 1; i++){ std::pair<int,int> nextTime = sched.getNextTime(); std::cout << nextTime.first << " " << nextTime.second << std::endl; //The possible cases. if(nextTime.second < prevTime.second){ // Don't need to check the front because the list has been sorted. std::cout << "1 " << curLongBlock << " " << maxLongBlock << std::endl; } else if ( nextTime.first <= curLastFarmTime && nextTime.second > curLastFarmTime){ curLongBlock += nextTime.second - curLastFarmTime; if(curLongBlock > maxLongBlock) maxLongBlock = curLongBlock; std::cout << "2 " << curLongBlock << " " << maxLongBlock << std::endl; } else if ((nextTime.first <= prevTime.second) && (nextTime.second > prevTime.second)) { curLongBlock += nextTime.second - prevTime.second; if(curLongBlock > maxLongBlock){ maxLongBlock = curLongBlock; } std::cout << "3 " << curLongBlock << " " << maxLongBlock << std::endl; } else if((nextTime.first > prevTime.second) && (nextTime.second > prevTime.second)){ curLongBlock = nextTime.second - nextTime.first; if(curLongBlock > maxLongBlock){ maxLongBlock = curLongBlock; } std::cout << "4 " << curLongBlock << " " << maxLongBlock << std::endl; if((curLastFarmTime < nextTime.second) &&(nextTime.first - prevTime.second > maxLongNonFarmBlock)){ maxLongNonFarmBlock = nextTime.first - prevTime.second; } } if(nextTime.second > curLastFarmTime) curLastFarmTime = nextTime.second; prevTime = nextTime; } createOutput(maxLongBlock, maxLongNonFarmBlock); return 0; }
int main(void) { setvbuf(stdout, NULL, _IONBF, 0); char myName[MAX_NAME_TOTAL][MAX_NAME_LENGTH]; int myRank[MAX_NAME_TOTAL][MAX_RANK_LENGTH]; init(myName, myRank); char fileNames[MAX_FILE][MAX_NAME_LENGTH] = {{"yob1920.txt"}, {"yob1930.txt"}, {"yob1940.txt"}, {"yob1950.txt"}, {"yob1960.txt"}, {"yob1970.txt"}, {"yob1980.txt"}, {"yob1990.txt"}, {"yob2000.txt"}, {"yob2010.txt"} }; readFiles(*fileNames,myName, myRank); sort(myName, myRank); createOutput(myName, myRank); return 0; }
bool QmmpAudioEngine::play() { if(isRunning() || m_decoders.isEmpty() || (m_output && m_output->isRunning())) return false; if(m_output) delete m_output; prepareEffects(m_decoders.head()); if(!(m_output = createOutput())) return false; #ifdef Q_OS_WIN start(QThread::HighPriority); #else start(); #endif return true; }
// ------------------------------------------------------------------------ void createLabelImage(const SeriesTransform &series, const ImageType::Pointer &reference, const LevelSetType::Pointer &levelSet, const std::vector<int> &roiOffset, ImageType::Pointer &label, unsigned int instance) { // initialise the label image createOutput(series.images[instance], label); // create the level set interpolator typedef itk::LinearInterpolateImageFunction<LevelSetType> InterpolatorType; InterpolatorType::Pointer interpolator = InterpolatorType::New(); interpolator->SetInputImage(levelSet); // iterate through the output itk::ImageRegionIterator<ImageType> it(label, label->GetLargestPossibleRegion()); it.GoToBegin(); while(!it.IsAtEnd()) { ImageType::IndexType index = it.GetIndex(); ImageType::PointType p1, p2; // get the point in the level set space label->TransformIndexToPhysicalPoint(index, p1); transformPointToPatient(reference, series, roiOffset, p1, p2); // interpolate the level set value if(interpolator->IsInsideBuffer(p2)) { float val = interpolator->Evaluate(p2); if(val >= 0) it.Set(1); } ++it; } }
void GrepWidget::InitWidget() { textLabel = new QLabel(tr("Containing text:")); textComboBox = createComboBox(); QLineEdit *edit = textComboBox->lineEdit(); Q_ASSERT(connect(edit, SIGNAL(returnPressed ()), this, SLOT(SlotTextEdited()))); findButton = createButton(tr("&Find"), SLOT(find())); createOutput(); QGridLayout *mainLayout = new QGridLayout; mainLayout->setSizeConstraint(QLayout::SetNoConstraint); mainLayout->addWidget(textLabel, 0, 0); mainLayout->addWidget(textComboBox, 0, 1, 1, 2); mainLayout->addWidget(output, 2, 0,1,3); mainLayout->addWidget(findButton, 3, 2); setLayout(mainLayout); }
TAC_NODE* generateTacCode(ASTREE* syntaxtree) { int i; TAC_NODE* code[MAX_SONS]; for(i=0; i < MAX_SONS; i++) { code[i] = NULL; } if(syntaxtree == NULL) return NULL; for (i=0; i < MAX_SONS; i++) { code[i] = generateTacCode(syntaxtree->son[i]); } switch (syntaxtree->type) { case AST_PROGRAMA: return code[0]; case AST_DECLARACOES: return joinTacs(code[0], code[1]); case AST_VARIAVEL: if(code[2]!=NULL) { return createTacNode(TAC_DECLARACAO_VARIAVEL, code[0]->result, code[2]->result, NULL); } else { return createTacNode(TAC_SYMBOL, code[0]->result, NULL, NULL); } case AST_VETOR_VAZIO: return createTacNode(TAC_DECLARACAO_VETOR_VAZIO, code[0]->result, code[2]->result, NULL); case AST_VETOR: return joinTacs(createTacNode(TAC_DECLARACAO_VETOR, code[0]->result, code[2]->result, NULL), initializeVector(revertTac(code[3]),code[0]->result,0)); case AST_INI_VETOR: return joinTacs(code[0], code[1]); case AST_LISTA_LITERAIS: return joinTacs(code[0], code[1]); case AST_FUNCAO: return createFunctionDeclaration(code[0]->result, code[2], code[3]); case AST_PARAMETRO: return createTacNode(TAC_PARAMETRO, code[0]->result, code[1]->result, NULL); case AST_LISTA_PARAMETRO: return joinTacs(code[0], code[1]); case AST_COMANDOS: return joinTacs(code[0], code[1]); case AST_BLOCO: return code[0]; case AST_LISTA_PARAM_CHAMADA: return joinTacs(code[0], code[1]); case AST_ACESSO_VETOR: return createVectorRead(code[0]->result, code[1]); case AST_CHAMADA_FUNCAO: return createFunctionCall(code[0]->result, code[1]); case AST_EXPRESSAO_PARENTESES: return code[0]; case AST_OP_SOMA: return createTacOperation(TAC_OP_SOMA, code[0], code[1]); case AST_OP_SUB: return createTacOperation(TAC_OP_SUB, code[0], code[1]); case AST_OP_MUL: return createTacOperation(TAC_OP_MUL, code[0], code[1]); case AST_OP_DIV: return createTacOperation(TAC_OP_DIV, code[0], code[1]); case AST_OP_MENOR: return createTacOperation(TAC_OP_MENOR, code[0], code[1]); case AST_OP_MAIOR: return createTacOperation(TAC_OP_MAIOR, code[0], code[1]); case AST_OP_LE: return createTacOperation(TAC_OP_LE, code[0], code[1]); case AST_OP_GE: return createTacOperation(TAC_OP_GE, code[0], code[1]); case AST_OP_EQ: return createTacOperation(TAC_OP_EQ, code[0], code[1]); case AST_OP_NE: return createTacOperation(TAC_OP_NE, code[0], code[1]); case AST_OP_AND: return createTacOperation(TAC_OP_AND, code[0], code[1]); case AST_OP_OR: return createTacOperation(TAC_OP_OR, code[0], code[1]); case AST_ATRIBUICAO: return joinTacs(code[1], createTacNode(TAC_ATRIBUICAO, code[0]->result, resultAtribuicao(code[1])->result, NULL)); case AST_ATRIBUICAO_VETOR: return createAssignVector(code[0]->result, resultAtribuicao(code[1]), resultAtribuicao(code[2])); case AST_IF: return createIF(code[0],code[1]); case AST_IF_ELSE: return createIF_ELSE(code[0],code[1],code[2]); case AST_WHILE: return createWHILE(code[0], code[1]); case AST_INPUT: return createInput(revertTac(code[0])); case AST_LISTA_VARIAVEIS: return joinTacs(code[0], code[1]); case AST_OUTPUT: return createOutput(revertTac(code[0])); case AST_LISTA_ELEM_EXP: return joinTacs(code[0], code[1]); case AST_LISTA_ELEM_STRING: return joinTacs(createTacNode(TAC_STRING, syntaxtree->symbol, NULL, NULL), code[0]); case AST_RETURN: return joinTacs(code[0], createTacNode(TAC_RETURN, code[0]->result, NULL, NULL)); case AST_KW_INT: return createTacNode(TAC_KW_INT, syntaxtree->symbol, NULL, NULL); case AST_KW_BOOL: return createTacNode(TAC_KW_BOOL, syntaxtree->symbol, NULL, NULL); case AST_KW_REAL: return createTacNode(TAC_KW_REAL, syntaxtree->symbol, NULL, NULL); case AST_KW_CHAR: return createTacNode(TAC_KW_CHAR, syntaxtree->symbol, NULL, NULL); case AST_LIT_INT: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_LIT_REAL: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_LIT_TRUE: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_LIT_FALSE: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_LIT_CHAR: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_LIT_STRING: return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL); case AST_COMANDO_VAZIO: return NULL; case AST_SYMBOL_VAR: return createTacNode(TAC_SYMBOL_VAR, syntaxtree->symbol, NULL, NULL); case AST_SYMBOL_VET: return createTacNode(TAC_SYMBOL_VET, syntaxtree->symbol, NULL, NULL); case AST_SYMBOL_FUN: return createTacNode(TAC_SYMBOL_FUN, syntaxtree->symbol, NULL, NULL); default: break; } }
int main(int argc, char **argv) { int special; plld = argv[0]; argc--; argv++; catchSignals(); if ( argc == 0 ) { fprintf(stderr, "No input files. Use %s -help.\n", plld); exit(0); } putenv("PLLD=true"); /* for subprograms */ verbose = FALSE; if ( argc > 2 && streq(argv[0], "-pl") ) special = 2; else special = 0; /* swipl-ld [-pl x] -v: verbose */ if ( argc-special == 1 && streq(argv[special], "-v") ) { arglist coptions; int i; memset(&coptions, 0, sizeof(coptions)); for(i=special; i < argc; i++) appendArgList(&coptions, argv[i]); callprog(PROG_CC, &coptions); return 0; } parseOptions(argc, argv); defaultProgram(&pl, PROG_PL); if ( build_defaults ) { nostate = TRUE; /* not needed and Prolog won't run */ defaultProgram(&cc, C_CC); #ifdef PLBASE defaultPath(&plbase, PLBASE); #else defaultPath(&plbase, PLHOME); #endif defaultPath(&plarch, PLARCH); defaultProgram(&pllib, C_PLLIB); addOptionString(C_LIBS); appendArgList(&ldoptions, C_LDFLAGS); appendArgList(&coptions, C_CFLAGS); appendArgList(&cppoptions, C_CFLAGS); #ifdef SO_EXT soext = strdup(SO_EXT); #endif #ifdef O_PLMT ensureOption(&coptions, "-D_REENTRANT"); ensureOption(&cppoptions, "-D_REENTRANT"); #ifdef _THREAD_SAFE /* FreeBSD */ ensureOption(&coptions, "-D_THREAD_SAFE"); ensureOption(&cppoptions, "-D_THREAD_SAFE"); #endif #endif } else { getPrologOptions(); } fillDefaultOptions(); if ( show_version ) { callprog(cc, &coptions); exit(0); } compileObjectFiles(); if ( !nolink ) { if ( shared ) linkSharedObject(); else { linkBaseExecutable(); if ( !nostate ) { createSavedState(); createOutput(); } } } removeTempFiles(); return 0; }
void ArmMotionEngine::updateArm(Arm& arm, ArmMotionEngineOutputBH& armMotionEngineOutput) { // assume arm should not be moved. armMotionEngineOutput.arms[arm.id].move = false; // make sure to not interfere with other motion engines if(theFallDownStateBH.state == FallDownStateBH::onGround || theMotionInfoBH.motion == MotionInfoBH::getUp) { arm.isMotionActive = false; return; } if(newMotionPossible(arm)) { // no motion is active, so decide what to do. // behavior overrides contact triggered motions if(theArmMotionRequestBH.motion[arm.id] != ArmMotionRequestBH::useDefault) { ArmMotion nextMotion = allMotions[theArmMotionRequestBH.motion[arm.id]]; arm.contactTriggered = false; arm.startMotion(nextMotion, theArmMotionRequestBH.fast[arm.id], theArmMotionRequestBH.autoReverse[arm.id], theArmMotionRequestBH.autoReverseTime[arm.id], theFilteredJointDataBH); } else if(theFrameInfoBH.getTimeSince(arm.lastContactAction) > actionDelay && (arm.id == ArmMotionRequestBH::left ? theArmContactModelBH.contactLeft : theArmContactModelBH.contactRight)) { #ifdef TARGET_ROBOT // check for armcontact ArmContactModelBH::PushDirection dir = (arm.id == ArmMotionRequestBH::left) ? theArmContactModelBH.pushDirectionLeft : theArmContactModelBH.pushDirectionRight; switch(dir) { case ArmContactModelBH::S: case ArmContactModelBH::SW: case ArmContactModelBH::SE: arm.lastContactAction = theFrameInfoBH.time; arm.contactTriggered = true; arm.startMotion(allMotions[ArmMotionRequestBH::back], false, true, targetTime, theFilteredJointDataBH); break; default: break; } #endif } } // when falling, try to set emergency mode fast if(theFallDownStateBH.state == FallDownStateBH::falling && arm.isMotionActive && arm.currentMotion.id != ArmMotionRequestBH::falling) { arm.startMotion(allMotions[ArmMotionRequestBH::falling], true, false, 0, theFilteredJointDataBH); } else if((theFallDownStateBH.state == FallDownStateBH::falling || theFallDownStateBH.state == FallDownStateBH::onGround || !theGroundContactStateBH.contact) && !arm.isMotionActive) { // fallen return; } else if(theMotionInfoBH.motion == MotionInfoBH::bike && arm.isMotionActive && arm.currentMotion.id != ArmMotionRequestBH::useDefault) { arm.startMotion(allMotions[ArmMotionRequestBH::useDefault], true, false, 0, theFilteredJointDataBH); } // test whether a motion is active now if(arm.isMotionActive) { // a motion is active, so decide what to do if(arm.stateIndex == arm.currentMotion.states.size()) { // arm reached its motion target ++arm.targetTime; if(arm.currentMotion.id == ArmMotionRequestBH::useDefault) { // arm is in default position, so ARME won't output any angles armMotionEngineOutput.arms[arm.id].move = false; arm.isMotionActive = false; } else if((arm.autoReverse && arm.targetTime == arm.autoReverseTime) || // target time ran out (!theGroundContactStateBH.contact) || // ground contact lost (theArmMotionRequestBH.motion[arm.id] != arm.currentMotion.id && !arm.contactTriggered)) // different motion requested { // start a reversed motion to reach the default position arm.startMotion(arm.currentMotion.reverse(defaultPos), theArmMotionRequestBH.fast[arm.id], false, 0, theFilteredJointDataBH); } else { // stay in target position updateOutput(arm, armMotionEngineOutput, arm.currentMotion.getTargetState()); } } else { // target not yet reached, so interpolate between the states ArmMotion::ArmAngles nextState = arm.currentMotion.states[arm.stateIndex]; if(!arm.fast) { ArmMotion::ArmAngles result; createOutput(arm, nextState, arm.interpolationTime, result); updateOutput(arm, armMotionEngineOutput, result); if(arm.interpolationTime >= nextState.steps) { ++arm.stateIndex; arm.interpolationTime = 1; arm.interpolationStart = nextState; } } else { // no interpolation updateOutput(arm, armMotionEngineOutput, nextState); ++arm.stateIndex; arm.interpolationTime = 1; arm.interpolationStart = nextState; } } } }