PProbabilityEstimator TProbabilityEstimatorConstructor_m::operator()(PDistribution frequencies, PDistribution apriori, PExampleGenerator, const long &weightID, const int &) const
{ TProbabilityEstimator_FromDistribution *pefd = mlnew TProbabilityEstimator_FromDistribution(CLONE(TDistribution, frequencies));
  PProbabilityEstimator estimator = pefd;
  
  TDiscDistribution *ddist = pefd->probabilities.AS(TDiscDistribution);  
  if (ddist && (ddist->cases > 1e-20) && apriori) {
    TDiscDistribution *dapriori = apriori.AS(TDiscDistribution);
    if (!dapriori || (dapriori->abs < 1e-20))
      raiseError("invalid apriori distribution");
    
    float mabs = m/dapriori->abs;
    const float &abs = ddist->abs;
    const float &cases = ddist->cases;
    const float div = cases + m;
    if ((abs==cases) || !renormalize) {
      int i = 0;
      for(TDiscDistribution::iterator di(ddist->begin()), de(ddist->end()), ai(dapriori->begin());
          di != de;
          di++, ai++, i++)
         ddist->setint(i, (*di+*ai*mabs)/div);
    }
    else {
      int i = 0;
      for(TDiscDistribution::iterator di(ddist->begin()), de(ddist->end()), ai(dapriori->begin());
          di != de;
          di++, ai++, i++)
         ddist->setint(i, (*di / abs * cases + *ai*mabs)/div);
    }
  }
  else
    pefd->probabilities->normalize();
    
  return estimator;
}
StatusNotifier::StatusNotifier(MainWindow &w, QObject *parent) :
    QObject(parent),
    systrayMenu(nullptr),
    minimiseRestoreAction(nullptr),
    window(w)
{
    systray = new QSystemTrayIcon(this);
    systray->setIcon(QIcon(":/icons/icons/shadowsocks-qt5.png"));
    systray->setToolTip(QString("Shadowsocks-Qt5"));
    connect(systray, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason r) {
        if (r != QSystemTrayIcon::Context) {
            this->activate();
        }
    });

#ifdef Q_OS_UNIX
    QString de(getenv("XDG_CURRENT_DESKTOP"));
    useAppIndicator = appIndicatorDE.contains(de, Qt::CaseInsensitive);
    if (useAppIndicator) {
        createAppIndicator();
    } else {
#endif
        createSystemTray();
#ifdef Q_OS_UNIX
    }
#endif
}
// Run ctags in each source directory
void TagParserBase::ReadClasses()
{
  CmdIO cmdio(mainwin);
  CmdStr cmd=CtagsCmd();
  FXString currdir=FXSystem::getCurrentDirectory();
  FXRex rx("\\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$",FXRex::IgnoreCase);
  for (FXint i=0; i<DirList().no(); i++) {
    const FXString dir=DirList().at(i)->dirname();
    if (dir.empty()) { continue; }
    if (FXSystem::setCurrentDirectory(dir)) {
      FXDir de(dir);
      if (de.isOpen()) {
        FXString fn;
        while (de.next(fn)) {
          if (FXStat::isFile(fn) && (rx.search(fn,0,fn.length())>=0)) { cmd+=fn.text(); }
        }
        de.close();
        current_filename=FXString::null;
        cmdio.setUserData((void*)(FXival)i);
        cmdio.lines(cmd.text(),this,ID_READ_ALL_FILES_LINES);
      }
    }
  }
  FXSystem::setCurrentDirectory(currdir);
}
wxString EnvironmentConfig::DoExpandVariables(const wxString& in)
{
    wxString result(in);
    wxString varName, text;

    DollarEscaper de(result);
    while ( MacroManager::Instance()->FindVariable(result, varName, text) ) {

        wxString replacement;
        if(varName == wxT("MAKE")) {
            //ignore this variable, since it is probably was passed here
            //by the makefile generator
            replacement = wxT("___MAKE___");

        } else {

            //search for an environment with this name
            wxGetEnv(varName, &replacement);
        }
        result.Replace(text, replacement);
    }

    //restore the ___MAKE___ back to $(MAKE)
    result.Replace(wxT("___MAKE___"), wxT("$(MAKE)"));
    return result;
}
Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() {

	Set<DrawEdge> edges;

	PoolVector<Vector3> data=get_faces();
	int datalen=data.size();
	ERR_FAIL_COND_V( (datalen%3)!=0,Vector<Vector3>() );

	PoolVector<Vector3>::Read r=data.read();

	for(int i=0;i<datalen;i+=3) {

		for(int j=0;j<3;j++) {

			DrawEdge de(r[i+j],r[i+((j+1)%3)]);
			edges.insert(de);
		}

	}

	Vector<Vector3> points;
	points.resize(edges.size()*2);
	int idx=0;
	for (Set<DrawEdge>::Element*E=edges.front();E;E=E->next()) {

		points[idx+0]=E->get().a;
		points[idx+1]=E->get().b;
		idx+=2;
	}

	return points;

}
        /*!
          \brief Apply the preconditoner.

          \copydoc Preconditioner::apply(X&,const Y&)
        */
        virtual void apply (X& v, const Y& d)
        {
            // Extract part of d corresponding to elliptic part.
            Y de(Ae_.N());
            // Note: Assumes that the elliptic part comes first.
            std::copy_n(d.begin(), Ae_.N(), de.begin());

            // Solve elliptic part, extend solution to full.
            Y ve = solveElliptic(de);
            Y vfull(ILU_.N());
            vfull = 0.0;
            // Again assuming that the elliptic part comes first.
            std::copy(ve.begin(), ve.end(), vfull.begin());

            // Subtract elliptic residual from initial residual.
            // dmodified = d - A * vfull
            Y dmodified = d;
            A_.mmv(vfull, dmodified);

            // Apply ILU0.
            Y vilu(ILU_.N());
            Dune::bilu_backsolve(ILU_, vilu, dmodified);
            v = vfull;
            v += vilu;
            v *= relax_;
        }
Beispiel #7
0
static int replaceData( gdcm::Tag const &t, gdcm::DataSet &ds, const gdcm::DictEntry &entry, char const *str, gdcm::VL::Type const size ) {
    gdcm::DataElement de ( t );
    de.SetVR( ds.FindDataElement(t) ? ds.GetDataElement(t).GetVR() : entry.GetVR() );
    de.SetByteValue( str, size );
    ds.Replace( de );
    return 1;
}
void THISCLASS::OnStep() {
	if (! mCore->mDataStructureImageGray.mImage) {
		AddError(wxT("No input image."));
		return;
	}

	// Mask the image
	if (mMaskImage) {
		if ((mCore->mDataStructureImageGray.mImage->width != mMaskImage->width) || (mCore->mDataStructureImageGray.mImage->height != mMaskImage->height)) {
			AddError(wxT("Wrong mask size."));
			return;
		}

		if ((mMode == cMode_WhiteWhite) || (mMode == cMode_BlackWhite)) {
			cvOr(mCore->mDataStructureImageGray.mImage, mMaskImage, mCore->mDataStructureImageGray.mImage);
		} else {
			cvAnd(mCore->mDataStructureImageGray.mImage, mMaskImage, mCore->mDataStructureImageGray.mImage);
		}
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mCore->mDataStructureImageGray.mImage);
	}
}
void THISCLASS::OnStep() {
	IplImage *inputimage = mCore->mDataStructureInput.mImage;
	if (! inputimage) {
		return;
	}

	try {
		// We convert the input image to a color image
		if (inputimage->nChannels == 3) {
			// We already have a color image
			mCore->mDataStructureImageColor.mImage = inputimage;
		} else if (inputimage->nChannels == 1) {
			// Gray, convert to BGR
			PrepareOutputImage(inputimage);
			cvCvtColor(inputimage, mOutputImage, CV_GRAY2BGR);
			mCore->mDataStructureImageColor.mImage = mOutputImage;
		} else {
			// Other cases, we take the first channel and transform it in BGR
			PrepareOutputImage(inputimage);
			cvCvtPixToPlane(inputimage, mOutputImage, NULL, NULL, NULL);
			cvCvtColor(mOutputImage, mOutputImage, CV_GRAY2BGR);
			mCore->mDataStructureImageColor.mImage = mOutputImage;
		}
	} catch (...) {
		AddError(wxT("Conversion to gray failed."));
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mCore->mDataStructureImageColor.mImage);
	}
}
Beispiel #10
0
stream::input_sptr FilterType_XOR::apply(stream::input_sptr target) const
{
	stream::input_filtered_sptr st(new stream::input_filtered());
	filter_sptr de(new filter_xor_crypt(0, 0));
	st->open(target, de);
	return st;
}
Beispiel #11
0
stream::inout_sptr FilterType_EPFS::apply(stream::inout_sptr target,
	stream::fn_truncate resize) const
{
	stream::filtered_sptr st(new stream::filtered());
	filter_sptr de(new filter_lzw_decompress(
		9,   // initial codeword length (in bits)
		14,  // maximum codeword length (in bits)
		256, // first valid codeword
		0,   // EOF codeword is max codeword
		-1,  // reset codeword is max-1
		LZW_BIG_ENDIAN        | // bits are split into bytes in big-endian order
		LZW_NO_BITSIZE_RESET  | // bitsize doesn't go back to 9 after dict reset
		LZW_EOF_PARAM_VALID   | // Has codeword reserved for EOF
		LZW_RESET_PARAM_VALID   // Has codeword reserved for dict reset
	));
	filter_sptr en(new filter_lzw_compress(
		9,   // initial codeword length (in bits)
		14,  // maximum codeword length (in bits)
		256, // first valid codeword
		0,   // EOF codeword is max codeword
		-1,  // reset codeword is max-1
		LZW_BIG_ENDIAN        | // bits are split into bytes in big-endian order
		LZW_NO_BITSIZE_RESET  | // bitsize doesn't go back to 9 after dict reset
		LZW_EOF_PARAM_VALID   | // Has codeword reserved for EOF
		LZW_RESET_PARAM_VALID   // Has codeword reserved for dict reset
	));
	st->open(target, de, en, resize);
	return st;
}
void THISCLASS::OnStep() {
	// Get and check input image
	IplImage *inputimage = mCore->mDataStructureImageColor.mImage;
	if (! inputimage) {
		AddError(wxT("No input image."));
		return;
	}
	if (inputimage->nChannels != 3) {
		AddError(wxT("The input image is not a color image."));
		return;
	}

	// Check and update the background
	if (! mFinalImage) {
		mFinalImage = cvCloneImage(inputimage);
	} else if (mMode == sMode_Addition) {
		cvAdd(mFinalImage, inputimage, mFinalImage);
	} else if (mMode == sMode_Subtraction) {
		cvSub(mFinalImage, inputimage, mFinalImage);
	} else if (mMode == sMode_Multiplication) {
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mFinalImage);
	}
}
Beispiel #13
0
  void write_controls(const SfxOptions& options) {
    DisableEvents de(*this);

    set_list_pos(module_ctrl_id, ArcAPI::sfx().find_by_name(options.name));

    set_check(replace_icon_ctrl_id, options.replace_icon);
    set_text(icon_path_ctrl_id, options.icon_path);

    set_check(replace_version_ctrl_id, options.replace_version);
    set_text(ver_info_product_name_ctrl_id, options.ver_info.product_name);
    set_text(ver_info_version_ctrl_id, options.ver_info.version);
    set_text(ver_info_company_name_ctrl_id, options.ver_info.company_name);
    set_text(ver_info_file_description_ctrl_id, options.ver_info.file_description);
    set_text(ver_info_comments_ctrl_id, options.ver_info.comments);
    set_text(ver_info_legal_copyright_ctrl_id, options.ver_info.legal_copyright);

    set_check(append_install_config_ctrl_id, options.append_install_config);
    set_text(install_config_title_ctrl_id, options.install_config.title);
    set_text(install_config_begin_prompt_ctrl_id, options.install_config.begin_prompt);
    TriState value;
    if (options.install_config.progress == L"yes")
      value = triTrue;
    else if (options.install_config.progress == L"no")
      value = triFalse;
    else
      value = triUndef;
    set_check3(install_config_progress_ctrl_id, value);
    set_text(install_config_run_program_ctrl_id, options.install_config.run_program);
    set_text(install_config_directory_ctrl_id, options.install_config.directory);
    set_text(install_config_execute_file_ctrl_id, options.install_config.execute_file);
    set_text(install_config_execute_parameters_ctrl_id, options.install_config.execute_parameters);
  }
stream::input_sptr FilterType_Zone66::apply(stream::input_sptr target) const
{
	stream::input_filtered_sptr st(new stream::input_filtered());
	filter_sptr de(new filter_z66_decompress());
	st->open(target, de);
	return st;
}
Beispiel #15
0
zOPER_EXPORT void OPERATION
AbortTask( zCPCHAR cpcMessage )
{
   ZDriverException de( cpcMessage );
   THROW( &de );
// AfxThrowFileException( CFileException::generic, -1,
//                        cpcMessage ); // throw an exception here
}
Beispiel #16
0
void App::defineNewEntry()
{
    DefineEntry de(this, 0, true);
#ifndef DESKTOP
    de.showMaximized();
#endif
    if (de.exec())
        setModified(true);
}
stream::inout_sptr FilterType_Zone66::apply(stream::inout_sptr target,
	stream::fn_truncate resize) const
{
	stream::filtered_sptr st(new stream::filtered());
	filter_sptr de(new filter_z66_decompress());
	filter_sptr en(new filter_z66_compress());
	st->open(target, de, en, resize);
	return st;
}
void THISCLASS::OnStep() {
	// Get and check input image
	IplImage *inputimage = mCore->mDataStructureImageColor.mImage;
	if (! inputimage) {
		AddError(wxT("No input image."));
		return;
	}
	if (inputimage->nChannels != 3) {
		AddError(wxT("The input image is not a color image."));
		return;
	}

	// Check and update the background
	if (! mOutputImage) {
	  mOutputImage = cvCloneImage(inputimage);
	} else {
	  cvCopyImage(inputimage, mOutputImage);
	}
	if (! mBackgroundImage) {
		mBackgroundImage = cvCloneImage(mOutputImage);
	} else if (mUpdateProportion > 0) {
		if ((cvGetSize(mOutputImage).height != cvGetSize(mBackgroundImage).height) || (cvGetSize(mOutputImage).width != cvGetSize(mBackgroundImage).width)) {
			AddError(wxT("Input and background images do not have the same size."));
			return;
		}

		cvAddWeighted(mOutputImage, mUpdateProportion, mBackgroundImage, 1.0 - mUpdateProportion, 0, mBackgroundImage);
	}

	try {
		// Correct the tmpImage with the difference in image mean
		if (mCorrectMean) {
			mBackgroundImageMean = cvAvg(mBackgroundImage);
			CvScalar tmpScalar = cvAvg(mOutputImage);
			cvAddS(mOutputImage, cvScalar(mBackgroundImageMean.val[0] - tmpScalar.val[0], mBackgroundImageMean.val[1] - tmpScalar.val[1], mBackgroundImageMean.val[2] - tmpScalar.val[2]), mOutputImage);
		}

		// Background subtraction
		if (mMode == sMode_SubImageBackground) {
			cvSub(mOutputImage, mBackgroundImage, mOutputImage);
		} else if (mMode == sMode_SubBackgroundImage) {
			cvSub(mBackgroundImage, mOutputImage, mOutputImage);
		} else {
			cvAbsDiff(mOutputImage, mBackgroundImage, mOutputImage);
		}
	} catch (...) {
		AddError(wxT("Background subtraction failed."));
	}
	mCore->mDataStructureImageColor.mImage = mOutputImage;
	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mOutputImage);
	}
}
Beispiel #19
0
stream::inout_sptr FilterType_XOR::apply(stream::inout_sptr target,
	stream::fn_truncate resize) const
{
	stream::filtered_sptr st(new stream::filtered());
	// We need two separate filters, otherwise reading from one will
	// affect the XOR key next used when writing to the other.
	filter_sptr de(new filter_xor_crypt(0, 0));
	filter_sptr en(new filter_xor_crypt(0, 0));
	st->open(target, de, en, resize);
	return st;
}
Beispiel #20
0
void App::changeEntry()
{
    ChooseEntry ce(this, 0, true);
    Entry *entry;

    ce.fillList(entriesList);
#ifdef DESKTOP
    // FIXME: make this work for qpe as well
    ce.adjustSize();
#endif
    if (!ce.exec())
        return;

    if (ce.currentEntry() == -1)
        return;

    entry = entriesList->at(ce.currentEntry());

    DefineEntry de(this, 0, true);

    if (notes->isEntryUsed(entry->getName()))
    {
        QMessageBox::warning(this, tr("Warning"), tr("This entry is used in notes.\nChanges made to this entry will\naffect all nodes of this type."), 0, 0, 0);

        de.setIsUsed(true);
    }

    for (PropertyStruct *ps = entry->first(); ps; ps = entry->next())
    {
        de.addProperty(new PropertyBoxItem(ps));
    }

    // now part of setEditEntry: de.EntryName->setText(entry->getName());
    de.setEditEntry(entry);
#ifndef DESKTOP
    de.showMaximized();
#endif

#ifdef DEBUG
    qDebug("-- Change entry --");
#endif

    int r = de.exec();
    if (r && de.getIsUsed())
    {
        notes->deleteEntryProperties(entry->getName(), de.getDeletedProperties());
    }

    if (r && de.getIsUsed())
        notes->refreshCurrentItem();

    if (r)
        setModified(true);
}
Beispiel #21
0
    void OnMouseMove(suic::MouseEventArg& e)
    {
        if (IsMouseCaptured())
        {
            int iHorz = e.MousePoint().x - _prev.x;
            int iVert = e.MousePoint().y - _prev.y;

            int newPos = _trackStart;

            if (CoreFlags::Horizontal == _slider->GetOrientation())
            {
                newPos += iHorz;

                if (newPos < 0)
                {
                    newPos = 0;
                }

                if (newPos > _slider->RenderSize().cx - GetDesiredSize().cx)
                {
                    newPos = _slider->RenderSize().cx - GetDesiredSize().cx;
                }

                iHorz = newPos - _trackPos;
            }
            else
            {
                newPos += iVert;

                if (newPos < 0)
                {
                    newPos = 0;
                }

                if (newPos > _slider->RenderSize().cy - GetDesiredSize().cy)
                {
                    newPos = _slider->RenderSize().cy - GetDesiredSize().cy;
                }

                iVert = newPos - _trackPos;
            }

            if (ThumbDragDelta && newPos != _trackPos)
            {
                _trackPos = newPos;
   
                DragDeltaEventArg de(iHorz, iVert);

                ThumbDragDelta(de);
            }
        }
    }
void THISCLASS::OnStep() {
	// Get the input image
	IplImage* inputimage = mCore->mDataStructureImageGray.mImage;
	if (! inputimage) {
		AddError(wxT("No image on selected input."));
		return;
	}

	// Calculate non-zero elements
	if (mCalculateNonZero) {
		int non_zero= cvCountNonZero(inputimage);
		CommunicationMessage m(wxT("STATS_NONZERO"));
		m.AddInt(non_zero);
		mCore->mCommunicationInterface->Send(&m);
	}

	// Calculate sum
	if (mCalculateSum) {
		CvScalar sum= cvSum(inputimage);
		CommunicationMessage m(wxT("STATS_SUM"));
		m.AddDouble(sum.val[0]);
		mCore->mCommunicationInterface->Send(&m);
	}

	// Calculate mean and standard deviation
	if (mCalculateMeanStdDev) {
		CvScalar mean;
		CvScalar std_dev;
		cvAvgSdv(inputimage, &mean, &std_dev, NULL);
		CommunicationMessage m(wxT("STATS_MEANSTDDEV"));
		m.AddDouble(mean.val[0]);
		m.AddDouble(std_dev.val[0]);
		mCore->mCommunicationInterface->Send(&m);
	}

	// Calculate min and max
	if (mCalculateMinMax) {
		double min_val;
		double max_val;
		cvMinMaxLoc(inputimage, &min_val, &max_val, NULL, NULL, NULL);
		CommunicationMessage m(wxT("STATS_MINMAX"));
		m.AddDouble(min_val);
		m.AddDouble(max_val);
		mCore->mCommunicationInterface->Send(&m);
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(inputimage);
	}
}
void THISCLASS::OnStep() {
	if (! mCore->mDataStructureImageColor.mImage) {
		AddError(wxT("No input image."));
		return;
	}

	cvSmooth(mCore->mDataStructureImageColor.mImage, mCore->mDataStructureImageColor.mImage, mBlurType, mRadius, mRadius);

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mCore->mDataStructureImageColor.mImage);
	}
}
Beispiel #24
0
  INT_PTR dialog_proc(int msg, int param1, void* param2) {
    if (msg == DN_CLOSE && param1 >= 0 && param1 != cancel_ctrl_id) {
      options = read_controls();
    }
    else if (msg == DN_INITDIALOG) {
      set_control_state();
    }
    else if (msg == DN_BTNCLICK) {
      set_control_state();
    }
    else if (msg == DN_EDITCHANGE && param1 == module_ctrl_id) {
      set_control_state();
    }
    else if (msg == DN_EDITCHANGE && param1 == profile_ctrl_id) {
      unsigned profile_idx = get_list_pos(profile_ctrl_id);
      if (profile_idx != -1 && profile_idx < profiles.size()) {
        write_controls(profiles[profile_idx].options);
        set_control_state();
      }
    }

    if (msg == DN_EDITCHANGE || msg == DN_BTNCLICK) {
      unsigned profile_idx = static_cast<unsigned>(profiles.size());
      SfxOptions options;
      bool valid_options = true;
      try {
        options = read_controls();
      }
      catch (const Error&) {
        valid_options = false;
      }
      if (valid_options) {
        for (unsigned i = 0; i < profiles.size(); i++) {
          if (options == profiles[i].options) {
            profile_idx = i;
            break;
          }
        }
      }
      if (profile_idx != get_list_pos(profile_ctrl_id)) {
        DisableEvents de(*this);
        set_list_pos(profile_ctrl_id, profile_idx);
        set_control_state();
      }
    }

    return default_dialog_proc(msg, param1, param2);
  }
void THISCLASS::OnStep() {
	if (! mCore->mDataStructureImageBinary.mImage) {
		AddError(wxT("No input image."));
		return;
	}

	if (mIterations > 0) {
		cvErode(mCore->mDataStructureImageBinary.mImage, mCore->mDataStructureImageBinary.mImage, NULL, mIterations);
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mCore->mDataStructureImageBinary.mImage);
	}
}
Beispiel #26
0
void CBDB_Env::CleanLog()
{
    char **nm_list = 0;
    int ret =
        m_Env->log_archive(m_Env, &nm_list, DB_ARCH_ABS);
    BDB_CHECK(ret, "DB_ENV::CleanLog()");

    if (nm_list != NULL) {
        for (char** file = nm_list; *file != NULL; ++file) {
            LOG_POST_X(5, Info << "BDB_Env: Removing LOG file: " << *file);
            CDirEntry de(*file);
            de.Remove();
        }
        free(nm_list);
    }

}
void THISCLASS::OnStep() {
	// Get and check input image
	IplImage *inputimage = mCore->mDataStructureImageGray.mImage;
	if (! inputimage) {
		AddError(wxT("No input image."));
		return;
	}
	if (inputimage->nChannels != 1) {
		AddError(wxT("The input image is not a grayscale image."));
		return;
	}

	// Check the background image
	if (! mBackgroundImage) {
		AddError(wxT("No background image loaded."));
		return;
	}
	if ((cvGetSize(inputimage).height != cvGetSize(mBackgroundImage).height) || (cvGetSize(inputimage).width != cvGetSize(mBackgroundImage).width)) {
		AddError(wxT("Input and background images don't have the same size."));
		return;
	}

	try {
		// Correct the inputimage with the difference in image mean
		if (mCorrectMean) {
			cvAddS(inputimage, cvScalar(mBackgroundImageMean.val[0] - cvAvg(inputimage).val[0]), inputimage);
		}

		// Background subtraction
		if (mMode == sMode_SubImageBackground) {
			cvSub(inputimage, mBackgroundImage, inputimage);
		} else if (mMode == sMode_SubBackgroundImage) {
			cvSub(mBackgroundImage, inputimage, inputimage);
		} else {
			cvAbsDiff(inputimage, mBackgroundImage, inputimage);
		}
	} catch (...) {
		AddError(wxT("Background subtraction failed."));
	}

	// Set the display
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(inputimage);
	}
}
void THISCLASS::OnStep() {
	// Check input image
	IplImage *inputimage = mCore->mDataStructureInput.mImage;
	if (! inputimage) {
		return;
	}
	if (inputimage->nChannels != 1) {
		AddError(wxT("This component requires a grayscale input image."));
	}

	// Prepare the output image
	PrepareOutputImage(inputimage);

	// Convert
	try {
		switch (mBayerType) {
		case 0 :
			cvCvtColor(inputimage, mOutputImage, CV_BayerBG2BGR);
			break;
		case 1 :
			cvCvtColor(inputimage, mOutputImage, CV_BayerGB2BGR);
			break;
		case 2 :
			cvCvtColor(inputimage, mOutputImage, CV_BayerRG2BGR);
			break;
		case 3 :
			cvCvtColor(inputimage, mOutputImage, CV_BayerGR2BGR);
			break;
		default :
			AddError(wxT("Invalid Bayer Pattern Type"));
			return;
		}
	} catch (...) {
		AddError(wxT("Conversion from Bayer to BGR failed."));
	}

	// Set the output image on the color data structure
	mCore->mDataStructureImageColor.mImage = mOutputImage;

	// Let the Display know about our image
	DisplayEditor de(&mDisplayOutput);
	if (de.IsActive()) {
		de.SetMainImage(mCore->mDataStructureImageColor.mImage);
	}
}
Beispiel #29
0
void QDragManager::drop()
{
    if ( !dropWidget )
	return;

    delete qt_qws_dnd_deco;
    qt_qws_dnd_deco = 0;

    QDropEvent de( QCursor::pos() );
    QApplication::sendEvent( dropWidget, &de );

#ifndef QT_NO_CURSOR
    if ( restoreCursor ) {
	myRestoreOverrideCursor();
	restoreCursor = FALSE;
    }
#endif
}
Beispiel #30
0
void dtfit_sigmc(){
    TChain* tree = new TChain("TEvent");
    tree->Add("/home/vitaly/B0toDh0/Tuples/b2dh_sigmc_s1.root");
    tree->Add("/home/vitaly/B0toDh0/Tuples/b2dh_sigmc_s2.root");

    RooArgSet argset;
    RooRealVar mbc("mbc","mbc",mbc_min,mbc_max,"GeV"); argset.add(mbc);
    RooRealVar de("de","#DeltaE",-0.15,0.3,"GeV"); argset.add(de);
    de.setRange("signal",de_min,de_max);
    RooRealVar md("md","md",DMass-md_cut,DMass+md_cut,"GeV"); argset.add(md);
    RooRealVar mk("mk","mk",KMass-mk_cut,KMass+mk_cut,"GeV"); argset.add(mk);
    RooRealVar mpi0("mpi0","mpi0",Pi0Mass-mpi0_cut,Pi0Mass+mpi0_cut,"GeV"); argset.add(mpi0);
    RooRealVar bdtgs("bdtgs","bdtgs",0.98,1.); argset.add(bdtgs);
    RooRealVar atckpi_max("atckpi_max","atckpi_max",0.,atckpi_cut); argset.add(atckpi_max);

    RooDataSet ds("ds","ds",tree,argset);
    ds.Print();
}