void NeuronsImageWriter::write() { // make sure we have a recent id map updateInputs(); unsigned int numSections = _idMap->size(); if (_annotation) { _directory += std::string("_") + boost::lexical_cast<std::string>(*_annotation); } // prepare the output directory boost::filesystem::path directory(_directory); if (!boost::filesystem::exists(directory)) { boost::filesystem::create_directory(directory); } else if (!boost::filesystem::is_directory(directory)) { BOOST_THROW_EXCEPTION(IOError() << error_message(std::string("\"") + _directory + "\" is not a directory") << STACK_TRACE); } // save output images for (unsigned int i = 0; i < numSections; i++) { std::stringstream filename; filename << _directory << "/" << _basename << std::setw(4) << std::setfill('0') << i << ".tiff"; vigra::exportImage(srcImageRange(*(*_idMap)[i]), vigra::ImageExportInfo(filename.str().c_str())); } }
//BEGIN class MultiInputGate MultiInputGate::MultiInputGate(ICNDocument *icnDocument, bool newItem, const char *id, const QString &rectangularShapeText, bool invertedOutput, int baseWidth, bool likeOR) : SimpleComponent(icnDocument, newItem, id), m_bInvertedOutput(invertedOutput) { m_bLikeOR = likeOR; m_bDoneInit = false; m_numInputs = 0; m_distinctiveWidth = baseWidth; m_rectangularShapeText = rectangularShapeText; for (int i = 0; i < maxGateInput; ++i) { inLogic[i] = 0; inNode[i] = 0; } updateLogicSymbolShape(); updateInputs(2); init1PinRight(16); setup1pinElement(m_pOut, m_pPNode[0]->pin()); createProperty("numInput", Variant::Type::Int); property("numInput")->setCaption(i18n("Number Inputs")); property("numInput")->setMinValue(2); property("numInput")->setMaxValue(maxGateInput); property("numInput")->setValue(2); m_bDoneInit = true; }
void GeoDialog::geoMapChanged() { mLatitude = mMapWidget->latitude(); mLongitude = mMapWidget->longitude(); updateInputs(); }
static void checkForEvents() { bool event = false; if(LuiEventManager_isWaitingForEvent()) { event |=updateRC(); event |=updateBehaviors(); if(event) { ase_printf("#play escape.wav 50 1\n"); time_since_last_event = 0; } } else { event |= updateInputs(); if(event) { time_since_last_event = 0; ase_printf("EVENT!:::\n"); for(int i=0; i<LuiManager_getNumberOfInputDevices(); i++) { ase_printf("%i, ",LuiManager_getDeviceReadList()[i]); } ase_printf("\n"); } else { time_since_last_event++; } } if(time_since_last_event>100) { time_since_last_event=100; } }
void HeightController::loop() { updateInputs(); static bool leftOnPoint = true, rightOnPoint = true; // pidLoop updates outputVar automatically if (m_rightPidLoop.compute()) { // allow for some dead band if (m_rightOutputVar > m_rightInputVar + m_deadBand || m_rightOutputVar < m_rightInputVar - m_deadBand) { leftOnPoint = false; if (m_rightOutputVar < 0.0) m_rightFillDrv->setValue(static_cast<uint8_t>(m_rightOutputVar * -1)); // reverse value as it is negative else m_rightDumpDrv->setValue(static_cast<uint8_t>(m_rightOutputVar)); } else { leftOnPoint = true; } } if (m_leftPidLoop.compute()) { // left side if (m_leftOutputVar > m_leftInputVar + m_deadBand || m_leftOutputVar < m_leftInputVar - m_deadBand) { rightOnPoint = false; if (m_leftOutputVar < 0.0) m_leftFillDrv->setValue(static_cast<uint8_t>(m_leftOutputVar * -1)); // reverse value as it is negative else m_leftDumpDrv->setValue(static_cast<uint8_t>(m_leftOutputVar)); } else { rightOnPoint = true; } } // we reached our setpoints if (leftOnPoint && rightOnPoint) { switch (m_statePid->state()) { case PID::States::ToLowState: m_statePid->setState(PID::States::LowState); m_statePid->setUpdated(true); break; case PID::States::ToNormalState: m_statePid->setState(PID::States::NormalState); m_statePid->setUpdated(true); break; case PID::ToHighState: m_statePid->setState(PID::States::HighState); m_statePid->setUpdated(true); break; default: break; } } }
void GeoDialog::cityInputChanged() { if ( mCityCombo->currentIndex() != 0 ) { GeoData data = mGeoDataMap[ mCityCombo->currentText() ]; mLatitude = data.latitude; mLongitude = data.longitude; } else mLatitude = mLongitude = 0; updateInputs(); }
void ColorImageWriter<ImageType>::write(std::string filename) { LOG_DEBUG(colorimagewriterlog) << "requesting image update" << std::endl; updateInputs(); if (!_r.isSet() || !_g.isSet() || !_b.isSet()) { LOG_ERROR(colorimagewriterlog) << "no input image set" << std::endl; return; } if (filename == "") filename = _filename; LOG_DEBUG(colorimagewriterlog) << "attempting to write image" << std::endl; if (_r->shape() != _g->shape() || _r->shape() != _b->shape()) { LOG_ERROR(colorimagewriterlog) << "images are not of same size" << std::endl; return; } vigra::MultiArray<2, vigra::RGBValue<float> > rgbImage(_r->shape()); typename ImageType::iterator ri = _r->begin(); typename ImageType::iterator gi = _g->begin(); typename ImageType::iterator bi = _b->begin(); vigra::MultiArray<2, vigra::RGBValue<float> >::iterator rgb = rgbImage.begin(); while (rgb != rgbImage.end()) { rgb->red() = *ri; rgb->green() = *gi; rgb->blue() = *bi; ri++; gi++; bi++; rgb++; } // save to file vigra::exportImage(vigra::srcImageRange(rgbImage), vigra::ImageExportInfo(filename.c_str())); LOG_DEBUG(colorimagewriterlog) << "image written" << std::endl; }
void GeoDialog::sexagesimalInputChanged() { mLatitude = (double)( mLatDegrees->value() + (double)mLatMinutes->value() / 60 + (double)mLatSeconds->value() / 3600 ); mLatitude *= ( mLatDirection->currentIndex() == 1 ? -1 : 1 ); mLongitude = (double)( mLongDegrees->value() + (double)mLongMinutes->value() / 60 + (double)mLongSeconds->value() / 3600 ); mLongitude *= ( mLongDirection->currentIndex() == 1 ? -1 : 1 ); mUpdateSexagesimalInput = false; updateInputs(); }
void ImageExtractor::onInputSet(const pipeline::InputSetBase&) { LOG_ALL(imageextractorlog) << "input image stack set" << std::endl; updateInputs(); _images.resize(_stack->size()); // for each image in the stack for (unsigned int i = 0; i < _stack->size(); i++) { LOG_ALL(imageextractorlog) << "(re)setting output " << i << std::endl; _images[i] = (*_stack)[i]; LOG_ALL(imageextractorlog) << "image is " << _images[i]->width() << "x" << _images[i]->height() << std::endl; LOG_ALL(imageextractorlog) << "registering output 'image " << i << "'" << std::endl; registerOutput(_images[i], "image " + boost::lexical_cast<std::string>(i)); } }
unsigned int CostWriter::writeCosts() { updateInputs(); return _store->storeCost(_segments, _objective); }
void MinimalImpactTEDWriter::write(std::string filename) { updateInputs(); // Create the internal pipeline createPipeline(); // Remove the old file /*if( std::remove( filename ) != 0 ) { LOG_DEBUG(minimalImpactTEDlog) << "Old file to output minimal impact TED approximation sucessfully deleted." << std::endl; } else { LOG_DEBUG(minimalImpactTEDlog) << "Could not delete old file to output minimal impact TED approximation." << std::endl; }*/ // Get a vector with all gold standard segments. const std::vector<boost::shared_ptr<Segment> > goldStandard = _goldStandard->getSegments(); int constant = 0; LOG_DEBUG(minimalImpactTEDlog) << "in write function." << std::endl; // Loop through variables std::set<unsigned int> variables = _problemConfiguration->getVariables(); for ( unsigned int varNum = 0 ; varNum < variables.size() ; varNum++ ) { // Introduce constraints that flip the segment corresponding to the ith variable // compared to the goldstandard. // Is the segment that corresponds to the variable part of the gold standard? unsigned int segmentId = _problemConfiguration->getSegmentId(varNum); bool isContained = false; foreach (boost::shared_ptr<Segment> s, goldStandard) { if (s->getId() == segmentId) { isContained = true; } } LinearConstraint constraint; constraint.setRelation(Equal); if (isContained == true) { // Force segment to not be used in reconstruction constraint.setCoefficient(varNum,1.0); constraint.setValue(0); } else { // Force segment to be used in reconstruction constraint.setCoefficient(varNum,1.0); constraint.setValue(1); } _linearConstraints->add(constraint); _linearSolver->setInput("linear constraints",_linearConstraints); pipeline::Value<Errors> errors = _teDistance->getOutput("errors"); unsigned int sumErrors = errors->getNumSplits() + errors->getNumMerges() + errors->getNumFalsePositives() + errors->getNumFalseNegatives(); int sumErrorsInt = (int) sumErrors; if (isContained == true) { // Forced segment to not be part of the reconstruction. // This resulted in a number of errors that are going to be stored in the constant. // To make net 0 errors when the variable is on, minus the number of errors will be written to the file. writeToFile(filename, -sumErrorsInt, varNum, false); constant += sumErrorsInt; } else { // Forced segment to be part of the reconstruction. // This resulted in a number of errors that are going to be written to the file. writeToFile(filename, sumErrorsInt, varNum, false); } // Remove constraint _linearConstraints->removeLastConstraint(); } // Write constant to file writeToFile(filename, constant, 0, true); }
EarMobileUI::EarMobileUI(const Wt::WEnvironment& env) : Wt::WApplication(env) { setTitle("Ear Mobile interface"); this->log("notice")<<"Making mobile UI"; Wt::WBootstrapTheme *theme = new Wt::WBootstrapTheme(); /// theme->setResponsive(true); theme->setVersion(Wt::WBootstrapTheme::Version3); // this->removeMetaHeader(Wt::MetaHeaderType::MetaName,"viewport"); //this->addMetaHeader("viewport", // "width=device-width, height=device-height, initial-scale=2"); // this->addMetaHeader("viewport", // "width=1024"); setTheme(theme); Wt::WTemplate *html = new Wt::WTemplate(Wt::WString( "<div width='device-width' scale='4' >" "<div>" "${start-button} ${stop-button} ${play-time}" "</div>" "<div>" "${fragment-tree}" "</div>" "</div>" ),root()); this->log("notice")<<"Making button container"; //Wt::WContainerWidget *buttonContainer = new Wt::WContainerWidget(root()); //buttonContainer->setMaximumSize(500,Wt::WLength::Auto); //Wt::WHBoxLayout *buttonBox = new Wt::WHBoxLayout(); //buttonContainer->setLayout(buttonBox); playPauseButton = new Wt::WPushButton("Play from start"); //buttonBox->addWidget(playPauseButton); playPauseButton->clicked().connect(std::bind([=] () { this->log("notice")<<"interactnig to pause"; zmq_conn::interact(std::string("event:pause")); })); html->bindWidget("start-button",playPauseButton); Wt::WPushButton *stopButton = new Wt::WPushButton("Stop"); //buttonBox->addWidget(stopButton); html->bindWidget("stop-button",stopButton); stopButton->clicked().connect(std::bind([=] () { this->log("notice")<<"interactnig to stop"; zmq_conn::interact(std::string("event:stop")); })); stopButton->setMargin(5, Wt::Left); posText = new TimeWidget(); posText->setMargin(5, Wt::Left); html->bindWidget("play-time",posText); //buttonBox->addWidget(posText); // Wt::WContainerWidget *fragmentContainer = new Wt::WContainerWidget(root()); fragmentTree = new Wt::WTreeTable(); html->bindWidget("fragment-tree",fragmentTree); // fragmentTree->addColumn("",500); // fragmentTree->resize( // Wt::WLength(100,Wt::WLength::Unit::Percentage), //Width // Wt::WLength(80,Wt::WLength::Unit::Percentage)); //Heigth /* Wt::WTimer *inputtimer = new Wt::WTimer(); inputtimer->setInterval(2500); //For some reason, this actually segfaults (on a RPi) when it fires, before calling updateInputs. Calling updateInputs from any other place works, including the other timer. I'll try and find out the cause later, now it runs inputtimer->timeout().connect(std::bind([=] () { std::cout<< "updating inputs " <<std::endl; updateInputs(); })); inputtimer->start(); */ updateInputs(); Wt::WTimer *timer = new Wt::WTimer(); timer->setInterval(100); timer->timeout().connect(std::bind([=] () { Wt::Json::Object posj ; bool playing; Wt::Json::Object playingj; zmq::socket_t *socket = zmq_conn::connect(); posj = zmq_conn::interact(std::string("pos?"),socket); playingj = zmq_conn::interact(std::string("playing?"),socket); zmq_conn::disconnect(socket); Wt::Json::Value posjv = posj.get("pos"); const long long track_time = posjv; posText->setTime(track_time); mark_current_fragment(fragmentTree,track_time); playing = playingj.get("playing"); if (playing) { playPauseButton->setText("Pause"); } else { if(track_time > 0) { playPauseButton->setText("Continue"); } else { playPauseButton->setText("Play from start"); } } updateInputs(); })); timer->start(); }
void MultiInputGate::dataChanged() { updateInputs(QMIN(maxGateInput, dataInt("numInput"))); }
void GeoDialog::setLongitude( double longitude ) { mLongitude = longitude; updateInputs(); }
void GeoDialog::setLatitude( double latitude ) { mLatitude = latitude; updateInputs(); }
void MinimalImpactTEDWriter::write(std::string filename) { updateInputs(); initPipeline(); int limitToISI = -1; if (optionLimitToISI) limitToISI = optionLimitToISI.as<int>() - SliceHashConfiguration::sectionOffset; if (optionWriteTedConditions) filename = "minimalImpactTEDconditions.txt"; // append ISI number to output filename if (limitToISI >= 0) filename = filename + "_" + optionLimitToISI.as<std::string>(); if (optionWriteTedConditions) { LOG_USER(minimalImpactTEDlog) << "writing ted conditions to " << filename << std::endl; } else { LOG_USER(minimalImpactTEDlog) << "writing ted coefficients to " << filename << std::endl; } // Remove the old file if( remove( filename.c_str() ) != 0 ) { LOG_DEBUG(minimalImpactTEDlog) << "Old file to output minimal impact TED approximation sucessfully deleted." << std::endl; } else { LOG_DEBUG(minimalImpactTEDlog) << "Could not delete old file to output minimal impact TED approximation." << std::endl; } // Open file for writing std::ofstream outfile; outfile.open(filename.c_str()); // Get a vector with all gold standard segments. const std::vector<boost::shared_ptr<Segment> > goldStandard = _goldStandard->getSegments(); int constant = 0; // Loop through variables std::set<unsigned int> variables = _problemConfiguration->getVariables(); LOG_USER(minimalImpactTEDlog) << "computing ted coefficients for " << variables.size() << " variables" << std::endl; if (optionWriteTedConditions) { outfile << "# hash: [hashes of flipped segments]" << std::endl; } else { outfile << "numVar " << variables.size() << std::endl; outfile << "# var_num costs # hash value_in_gs fs fm fp fn ( <- when flipped )" << std::endl; } std::set<unsigned int> goldStandardIds; foreach (boost::shared_ptr<Segment> s, goldStandard) goldStandardIds.insert(s->getId()); // create a map from segment ids to segment pointers std::map<unsigned int, boost::shared_ptr<Segment> > idToSegment; foreach (boost::shared_ptr<Segment> segment, _segments->getSegments()) idToSegment[segment->getId()] = segment; for ( unsigned int varNum = 0 ; varNum < variables.size() ; varNum++ ) { unsigned int segmentId = _problemConfiguration->getSegmentId(varNum); int interSectionInterval = _problemConfiguration->getInterSectionInterval(varNum); if (limitToISI >= 0) if (interSectionInterval != limitToISI) continue; std::string timerMessage = "\n\nMinimalImpactTEDWriter: variable " + boost::lexical_cast<std::string>(varNum) + ", %ws\n\n"; boost::timer::auto_cpu_timer timer(timerMessage); // re-create the pipeline for the current segment and its inter-section // interval if (!optionWriteTedConditions) updatePipeline(interSectionInterval, optionNumAdjacentSections.as<int>()); // Is the segment that corresponds to the variable part of the gold standard? bool isContained = (goldStandardIds.count(segmentId) > 0); // get the hash value of this segment SegmentHash segmentHash = idToSegment[segmentId]->hashValue(); // pin the value of the current variable to its opposite _linearSolver->pinVariable(varNum, (isContained ? 0 : 1)); if (!optionWriteTedConditions) { pipeline::Value<TolerantEditDistanceErrors> errors = _teDistance->getOutput("errors"); int sumErrors = errors->getNumSplits() + errors->getNumMerges() + errors->getNumFalsePositives() + errors->getNumFalseNegatives(); outfile << "c" << varNum << " "; outfile << (isContained ? -sumErrors : sumErrors) << " "; outfile << "# "; outfile << segmentHash << " "; outfile << (isContained ? 1 : 0) << " "; outfile << errors->getNumSplits() << " "; outfile << errors->getNumMerges() << " "; outfile << errors->getNumFalsePositives() << " "; outfile << errors->getNumFalseNegatives() << std::endl; if (isContained) { // Forced segment to not be part of the reconstruction. // This resulted in a number of errors that are going to be stored in the constant. // To make net 0 errors when the variable is on, minus the number of errors will be written to the file. constant += sumErrors; } } else { pipeline::Value<Solution> solution = _linearSolver->getOutput("solution"); outfile << segmentHash << ":"; for (unsigned int i = 0; i < variables.size(); i++) { unsigned int id = _problemConfiguration->getSegmentId(i); // was flipped? if ((*solution)[i] != goldStandardIds.count(id)) outfile << " " << idToSegment[id]->hashValue(); } outfile << std::endl; } // Remove constraint _linearSolver->unpinVariable(varNum); } if (!optionWriteTedConditions) { // Write constant to file outfile << "constant " << constant << std::endl; } outfile.close(); }