void getExpShift(const Array2D8u& img1, const int median1, const Array2D8u& img2, const int median2, const int noise, const int shift_bits, int &shift_x, int &shift_y) { assert(img1.getCols() == img2.getCols()); assert(img1.getRows() == img2.getRows()); int curr_x = 0; int curr_y = 0; if (shift_bits > 0) { Array2D8u img1small(img1.getCols()/2, img1.getRows()/2); Array2D8u img2small(img2.getCols()/2, img2.getRows()/2); pfs::resize(img1, img1small); pfs::resize(img2, img2small); getExpShift(img1small, median1, img2small, median2, noise, shift_bits-1, curr_x, curr_y); curr_x *= 2; curr_y *= 2; } Array2Db img1threshold(img1.getCols(), img1.getRows()); Array2Db img1mask(img1.getCols(), img1.getRows()); Array2Db img2threshold(img2.getCols(), img2.getRows()); Array2Db img2mask(img2.getCols(), img2.getRows()); setThreshold(img1, median1, noise, img1threshold, img1mask); setThreshold(img2, median2, noise, img2threshold, img2mask); Array2Db img2_shifted(img2.getCols(), img2.getRows()); Array2Db img2mask_shifted(img2.getCols(), img2.getRows()); int minerr = img1.size(); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { int dx = curr_x + i; int dy = curr_y + j; pfs::shift(img2threshold, dx, dy, img2_shifted); pfs::shift(img2mask, dx, dy, img2mask_shifted); long err = XORimages(img1threshold, img1mask, img2_shifted, img2mask_shifted); if ( err < minerr ) { minerr = err; shift_x = dx; shift_y = dy; } } } PRINT_DEBUG("getExpShift::Level " << shift_bits << " shift (" << shift_x << "," << shift_y << ")"); }
//-------------------------------------------------------------- ofxUIMovingGraphThreshold::ofxUIMovingGraphThreshold(float w, float h, vector<float> _buffer, int _bufferSize, float _min, float _max, string _name) : ofxUIMovingGraph(w,h,_buffer,_bufferSize,_min,_max,_name) { setThreshold(0.0f); m_value = 0.0f; setState(""); }
void Phone::setup(int mode, int quality, int abr, int vbr, float vbr_quality, int complexity, int vad, int dtx, int txstop, int th, int ring_vol) { bool restart = recording; if (restart) stopRecorder(); if (enc_state) speex_encoder_destroy(enc_state); SpeexMode *spmode = NULL; switch (mode) { case IHU_NARROW: spmode = (SpeexMode *) &speex_nb_mode; break; case IHU_WIDE: spmode = (SpeexMode *) &speex_wb_mode; break; case IHU_ULTRAWIDE: spmode = (SpeexMode *) &speex_uwb_mode; break; } enc_state = speex_encoder_init(spmode); speex_encoder_ctl(enc_state, SPEEX_SET_COMPLEXITY, &complexity); if (vbr) { speex_encoder_ctl(enc_state, SPEEX_SET_VBR, &vbr); speex_encoder_ctl(enc_state, SPEEX_SET_VBR_QUALITY, &vbr_quality); } else { speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &quality); speex_encoder_ctl(enc_state, SPEEX_SET_VAD, &vad); } if (abr) speex_encoder_ctl(enc_state, SPEEX_SET_ABR, &abr); speex_encoder_ctl(enc_state, SPEEX_SET_DTX, &dtx); speex_encoder_ctl(enc_state, SPEEX_GET_SAMPLING_RATE, &rate); speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &frame_size); stoptx = txstop; speex_bits_init(&enc_bits); ring_vol = -ring_vol + 1; float vol = 0.0; if (ring_vol <= 0) vol = powf(VOL_FACTOR, (float) (ring_vol)); for (int i=0; i<SIZE_RING_32; i++) ringBuffer[i] = ((float) ring_32[i]) * vol; setThreshold(th); if (restart) startRecorder(); }
Graph& Graph::setup(string name, float threshold) { setName(name); if(threshold > 0) { setThreshold(threshold); } return *this; }
bool Meter::isMouseOnMeter(int x, int y){ if(x<thresholdBarLoc.x+thresholdBarSize.x&&x>thresholdBarLoc.x&&y>thresholdBarLoc.y&&y<thresholdBarLoc.y+thresholdBarSize.y){ cout<<"CLICK"<<endl; float value = 1.f-(y-thresholdBarLoc.y)/thresholdBarSize.y; cout << value<<endl; setThreshold(value); } }
//thresholds all images (glove2 needs all colors thresholded) void Detector::thresholdForGlove2(Mat src) { setThreshold('b'); blueThreshImg = segmentFrame(src); setThreshold('g'); greenThreshImg = segmentFrame(src); setThreshold('p'); pinkThreshImg = segmentFrame(src); setThreshold('r'); redThreshImg = segmentFrame(src); setThreshold('y'); yellowThreshImg = segmentFrame(src); }
void BinaryOutputElement::initBOR(int inputs, Align a, double threshold, ThresholdType tt) { intRect = boundingRect().adjusted(5, 5, -5, -5); setAligment(a); setInputSize(inputs); setThresholdType(tt); setThreshold(threshold); }
OMPLGoalState::OMPLGoalState(const ob::SpaceInformationPtr &si, OMPLProblem_ptr prob) : ob::GoalState(si), prob_(prob) { type_ = ob::GOAL_STATE; state_space_ = si->getStateSpace(); setThreshold(std::numeric_limits<double>::epsilon()); }
void NonGradient::initialize_mesh_iteration(PatchData &pd, MsqError &err) { int elementDimension = getPatchDimension( pd, err ); // to do: react to error int dimension = elementDimension * pd.num_free_vertices(); //printPatch( pd, err ); setDimension(dimension); int maxNumEval = 100*dimension; // 1. Make this a user parameter setMaxNumEval(maxNumEval); double threshold = 1.e-10; // avoid division by zero setThreshold(threshold); double minEdgeLen = 0.0; double maxEdgeLen = 0.0; // double ftol = 0.; if( dimension > 0 ) { pd.get_minmax_edge_length( minEdgeLen, maxEdgeLen ); //ftol = minEdgeLen * 1.e-4; // Turn off Amoeba convergence criterion if( mNonGradDebug >= 1 ) { std::cout << "minimum edge length " << minEdgeLen << " maximum edge length " << maxEdgeLen << std::endl; } MSQ_PRINT(3)("minimum edge length %e maximum edge length %e\n", minEdgeLen, maxEdgeLen); } // setTolerance(ftol); int numRow = dimension; int numCol = numRow+1; if( numRow*numCol <= simplex.max_size() ) { simplex.assign(numRow*numCol, 0.); // guard against previous simplex value double scale = minEdgeLen * mScaleDiameter;; const MsqVertex* coord = pd.get_vertex_array(err); if( pd.num_free_vertices() > 1 ) { MSQ_SETERR(err)("Only one free vertex per patch implemented", MsqError::NOT_IMPLEMENTED); } size_t index = 0; for( int col = 0; col < numCol; col++ ) { for (int row=0;row<numRow;row++) { simplex[ row + col*numRow ] = coord[index][row]; if( row == col-1 ) { simplex[ row + col*numRow ] += scale/ static_cast<double>(numCol); } } } } else { MSQ_SETERR(err)("Use patch with fewer free vertices", MsqError::OUT_OF_MEMORY); if( mNonGradDebug >= 1 ) { std::cout << "ERROR: Too many free vertices in patch" << std::endl; } //MSQ_PRINT(1)("ERROR: Too many free vertices in patch\n"); } }
ARTracker::ARTracker(DebugMode debugMode, int threshold, bool blurring){ setDebugMode(debugMode); setThreshold(threshold); setBlurring(blurring); initPerspectiveTransformTarget(); initModelPoints(); }
void ThresholdBar::updateGUI(){ if ( ofGetMousePressed() ){ float mouseX = ofGetMouseX(); float mouseY = ofGetMouseY(); if ((mouseX >= x ) && (mouseX <= x + width) && (mouseY >= y ) && (mouseY <= y + height)){ if ( !vertOriented ){ setThreshold( (mouseX - x) / width ); } else { setThreshold( 1.0 - ((mouseY - y) / height) ); } } } };
void Normalization::init(Normalization::Type nt, double max, double min, double threshold, double amp, double elong) { setType(nt); setMaxValue(max); setMinValue(min); setThreshold(threshold); setAmplitude(amp); setElongation(elong); }
void Adaline::setInputSize(int n) { if(n != (int) weights.size()){ setWeights(getRandomValues((int)n)); setThreshold(getRandomValues(1)[0]); }else{ qWarning("No se realizo cambio alguno porque el numero de entradas no vario"); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void Watershed::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setSelectedCellArrayPath( reader->readDataArrayPath( "SelectedCellArrayPath", getSelectedCellArrayPath() ) ); setFeatureIdsArrayName( reader->readString( "FeatureIdsArrayName", getFeatureIdsArrayName() ) ); setThreshold( reader->readValue( "Threshold", getThreshold() ) ); setLevel( reader->readValue( "Level", getLevel() ) ); reader->closeFilterGroup(); }
/*** PRIVATE SLOTS ***/ void ScoreDistribution::selected(const QPointF &point) { if ((qpmMarker.xValue() == point.x()) || (qpcLive.data()->size() <= 1)) return; setThreshold(point.x()); emit newThreshold(point.x()); }
LimiterImpl::LimiterImpl(int sampleRate) { sampleRate = MAX(sampleRate, 8000); sampleRate = MIN(sampleRate, 96000); _sampleRate = sampleRate; // defaults setThreshold(0.0f); setRelease(250.0f); }
bool ExecutionCounter::checkIfThresholdCrossedAndSet(CodeBlock* codeBlock) { if (hasCrossedThreshold(codeBlock)) return true; if (setThreshold(codeBlock)) return true; return false; }
void ChromaCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"chromablur") > 0) setSpread(pt.get<float>(L"chromablur")); if (pt.count(L"chromakey") > 0) setKey(QString::fromStdWString(pt.get<std::wstring>(L"chromakey"))); if (pt.count(L"chromasoftness") > 0) setSpread(pt.get<float>(L"chromasoftness")); if (pt.count(L"chromaspill") > 0) setSpill(pt.get<float>(L"chromaspill")); if (pt.count(L"chromathreshold") > 0) setThreshold(pt.get<float>(L"chromathreshold")); setShowMask(false); }
//virtual void ColorDetector::onValueChanged(QtProperty* property, void* id, const QVariant& variant) { // addIntProperty(tr("Threshold"), m_threshold, 0, 1000); // addColorProperty(tr("Target Color"), m_targetColor.toQColor()); if (id == m_threshold.id()) { setThreshold(variant.value<int>()); } else if (id == m_targetColor.id()) { setTargetColor(variant.value<QColor>()); } }
void Adaline::init(const vector<double> &weights, TransferFunctionType tf) { size_t sWeights = weights.size(); if(sWeights > 0){ setWeights(weights); setAlfa(1); setThreshold(getRandomValues(1)[0]); setTransferFunction(tf); }else{ qWarning() << "Se debe asignar al menos una entrada a un perceptron simple"; } }
void Compressor::setNValue(int idx, double value) { switch (idx) { case RMS_PEAK: setRmsPeak(value); break; case ATTACK: setAttack(value); break; case RELEASE: setRelease(value); break; case THRESHOLD: setThreshold(value); break; case RATIO: setRatio(value); break; case KNEE: setKnee(value); break; case GAIN: setMakeupGain(value); break; } }
Normalization &Normalization::operator=(const Normalization &nor) { if(this != &nor){ setMaxValue(nor.getMaxValue()); setMinValue(nor.getMinValue()); setThreshold(nor.getThreshold()); setType(nor.getType()); setAmplitude(nor.getAmplitude()); setElongation(nor.getElongation()); } return *this; }
//------------------------------------------------------------------------------ // setSlotThreshold() -- converts a power to watts and sets our antenna threshold //------------------------------------------------------------------------------ bool Antenna::setSlotThreshold(Basic::Power* const p) { bool ok = false; // Has power units and we need watts Basic::Watts watts; double x = watts.convert(*p); // Test and set the threshold if (x >= 0.0) ok = setThreshold(x); return ok; }
void SetupSinal::setRFData(Matrix rf) { rfdata = rf; env = rfdata; time_cut = rfdata; //para garantir que o valor do vetor de limiar seja do mesmo tamanho do sinal limiar = rfdata; setThreshold(v_limiar); imgproc.hilbert(env); env_gain = env; }
static void setConfig(void* self, const char* name, const char* value) { PODConfigurationElement* cfgElement; /* * Find the named item. */ for (cfgElement = this->mConfig; cfgElement->name != NULL; cfgElement++) { if (strcmp(name, cfgElement->name) == 0) { break; } } /* * Cant set that which does not exist! */ if ( !cfgElement->name ) { return; } /* * OK time to do some work... */ if (strcmp(name, CFG_STATUS) == 0) { if (strcmp(value, CFG_ACTION_ENABLE) == 0) { talpa_mutex_lock(&this->mConfigSerialize); enable(this); talpa_mutex_unlock(&this->mConfigSerialize); } else if (strcmp(value, CFG_ACTION_DISABLE) == 0) { talpa_mutex_lock(&this->mConfigSerialize); disable(this); talpa_mutex_unlock(&this->mConfigSerialize); } } else if ( !strcmp(name, CFG_THRESHOLD) ) { talpa_mutex_lock(&this->mConfigSerialize); setThreshold(this, value); talpa_mutex_unlock(&this->mConfigSerialize); } return; }
// setSlotThreshold() - Sets Signal to Noise Threshold bool IrSensor::setSlotThreshold(const base::Number* const msg) { bool ok = false; if (msg != nullptr) { double x = msg->getReal(); ok = setThreshold(x); if (!ok) { if (isMessageEnabled(MSG_ERROR)) { std::cerr << "IrSensor::setSlotThreshold: Error setting Signal to Noise Threshold!" << std::endl; } } } return ok; }
void IndicatorLight::loadSettings(QSettings &settings) { PanelItem::loadSettings(settings); setDataRefName(settings.value("datarefname","sim/cockpit/misc/compass_indicated").toString()); setThreshold(settings.value("threshold","0.1").toDouble()); setStrengthOn(settings.value("strengthon","100").toInt()); setStrengthOff(settings.value("strengthoff","20").toInt()); setLabelOn(settings.value("labelon","BRAKES").toString()); setLabelOff(settings.value("labeloff","BRAKES").toString()); setLabelColor(QColor(settings.value("labelcolor","red").toString())); setGlowStrength(settings.value("glowstrength","80").toInt()); DEBUG << _datarefName; }
virtual bool init() { // Work with luminance images setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM); if ( ! checkPixelFormat()) { if (logger) logger->artLog("ARToolKitPlus: Invalid Pixel Format!"); return false; } // Memory if (marker_infoTWO == NULL) marker_infoTWO = ARToolKitPlus::artkp_Alloc<ARToolKitPlus::ARMarkerInfo2>(32); // Camera Camera *camera = new Camera(screenWidth, screenHeight); setCamera(camera, 1, 1000); // const ARFloat* mat = getProjectionMatrix(); // printf("Proj mat\n"); // for(int j=0; j<4; j++) { // for(int i=0; i<4; i++) { // printf ("%f, ", mat[i*4 + j]); // } // printf ("\n"); // } // Work at full res setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES); // Set border setBorderWidth(0.125); // Set threshold and activate automatic threshold setThreshold(160); activateAutoThreshold(true); setNumAutoThresholdRetries(2); // Switch to BCH ID based markers setMarkerMode(ARToolKitPlus::MARKER_ID_BCH); // Choose pose estimator setPoseEstimator(ARToolKitPlus:: //POSE_ESTIMATOR_ORIGINAL); //POSE_ESTIMATOR_ORIGINAL_CONT); POSE_ESTIMATOR_RPP); return true; }
void IndicatorDisplay::loadSettings(QSettings &settings) { PanelItem::loadSettings(settings); setDataRefName(settings.value("datarefname","sim/cockpit/misc/compass_indicated").toString()); setThreshold(settings.value("threshold","0.1").toDouble()); setStrengthOn(settings.value("strengthon","100").toInt()); setStrengthOff(settings.value("strengthoff","20").toInt()); setLabelOn(settings.value("labelon","BRAKES").toString()); setLabelOff(settings.value("labeloff","BRAKES").toString()); setLabelColor(QColor(settings.value("labelcolor","white").toString())); setValueColor(QColor(settings.value("valuecolor","white").toString())); setShowValue(settings.value("showvalue","false").toString()=="true"); setValueDivisor(settings.value("valuedivisor","1").toInt()); DEBUG << _datarefName; }
QPoint RedEyeDetection::locateStartingPoint(const QImage &image, const QRect &rect) const { // Find optimal starting point (one with highest red value // relative to green and blue) const int coeflen = 6; const int coefs[13] = {28, 39, 48, 55, 60, 63, 64, 63, 60, 55, 48, 39, 28}; // 8*8 - {0,1,2...}^2 QPoint centerMax = QPoint(); int redMax = 0, redRatio = 0; // The center point is set in full-image coordinates setThreshold(0); int x_c = rect.center().x(); int y_c = rect.center().y(); int d_max = qMax(rect.width()/2, rect.height()/2); for (int y=rect.top(); y<=rect.bottom(); y++) { int y_coef = coefs[(coeflen*(y-y_c))/d_max + coeflen]; for (int x=rect.left(); x <= rect.right(); x++) { QRgb rgb = image.pixel(QPoint(x, y)); if (isRedEyePixel(rgb)) { redRatio = qRed(rgb) * 255 / (qRed(rgb) + qGreen(rgb) + qBlue(rgb)); int x_coef = coefs[(coeflen*(x-x_c))/d_max + coeflen]; redRatio *= x_coef + y_coef; if (redRatio > redMax) { redMax = redRatio; centerMax = QPoint(x, y); } } } } return centerMax; }