当前位置: 首页>>代码示例>>C++>>正文


C++ Scalar类代码示例

本文整理汇总了C++中Scalar的典型用法代码示例。如果您正苦于以下问题:C++ Scalar类的具体用法?C++ Scalar怎么用?C++ Scalar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Scalar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cvtColor

void Feature::calcColorFeature()
{
    // TODO: optimize this part, reduce extra work
    
    Mat hsv;
    cvtColor(mROI, hsv, CV_BGR2HSV_FULL);
    
    Mat temp(mROI.size(), CV_8UC3), mixed;
    Mat src[] = { mROI, mGray, hsv };
    int fromTo[] = { 2,0, 3,1, 5,2 };
    mixChannels(src, 3, &temp, 1, fromTo, 3);
    temp.convertTo(mixed, CV_64F);
    
    Scalar avg, stdDev;
    meanStdDev(mixed, avg, stdDev, mMask);
    Scalar var = stdDev.mul(stdDev);
    Mat temp1 = mixed - avg;
    Mat temp2 = temp1.mul(temp1);
    Scalar sk = mean(temp1.mul(temp2), mMask) / (var.mul(stdDev));
    Scalar ku = mean(temp2.mul(temp2), mMask) / (var.mul(var));
    
    Scalar stat[] = { avg, stdDev, sk, ku };
    for (int i = 0; i < 4; i++) {
        red[i] = stat[i][0];
        gray[i] = stat[i][1];
        saturation[i] = stat[i][2];
    }
}
开发者ID:nikola1234,项目名称:analyzeServer,代码行数:28,代码来源:FeatureAnalyzer.cpp

示例2: WriteMemory

void
IRMemoryMap::WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Error &error)
{
    error.Clear();
    
    if (size == UINT32_MAX)
        size = scalar.GetByteSize();
    
    if (size > 0)
    {
        uint8_t buf[32];
        const size_t mem_size = scalar.GetAsMemoryData (buf, size, GetByteOrder(), error);
        if (mem_size > 0)
        {
            return WriteMemory(process_address, buf, mem_size, error);
        }
        else
        {
            error.SetErrorToGenericError();
            error.SetErrorString ("Couldn't write scalar: failed to get scalar as memory data");
        }
    }
    else
    {
        error.SetErrorToGenericError();
        error.SetErrorString ("Couldn't write scalar: its size was zero");
    }
    return;
}
开发者ID:Jean-Daniel,项目名称:lldb,代码行数:29,代码来源:IRMemoryMap.cpp

示例3: addScalar

void TimeAnalysisWidget::on_applyButton_clicked()
{
    bool low = _ui->lowRadioButton->isChecked();
    int numClusters = _ui->numClustersSpin->value();
    std::vector<Point*> &points = low?_lowPoints.data():_highPoints.data();

    std::vector<Point> centers;
    std::vector<int> assignment;
    PointClusterer::kmeans(PointClusterer::RANDOM,numClusters,
                           PointClusterer::EUCLIDEAN,
                           points, 10, centers, assignment);

    std::ostringstream ss;
    ss << "K-means " << numClusters << (low?" [low]":" [high]");
    Scalar *scalar = addScalar(ss.str());

    // create labels
    scalar->labels().clear();
    for (unsigned i=0; i<centers.size(); ++i) {
        ss.str("");
        ss << "Cluster [" << i << "]";
        scalar->labels().push_back(ss.str());
    }

    // assigne scalar values to points
    for (unsigned i=0; i<assignment.size(); ++i) {
        Point *p = _lowPoints.data()[i];
        p->setScalarValue(scalar, assignment[i]);
    }

    // refill combox
    fillScalarComboBox();
    _ui->colorByComboBox->setCurrentIndex(scalar->index());
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:34,代码来源:timeanalysiswidget.cpp

示例4: TEST

TEST(ScalarTest, Division) {
  Scalar lhs(5.0);
  Scalar rhs(2.0);
  Scalar r = lhs / rhs;
  EXPECT_TRUE(r.IsValid());
  EXPECT_EQ(r, Scalar(2.5));
}
开发者ID:llvm-project,项目名称:lldb,代码行数:7,代码来源:ScalarTest.cpp

示例5: exe_ctx

    virtual bool
    Execute 
    (
        Args& command,
        CommandReturnObject &result
    )
    {
        DataExtractor reg_data;
        ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
        RegisterContext *reg_context = exe_ctx.GetRegisterContext ();

        if (reg_context)
        {
            if (command.GetArgumentCount() != 2)
            {
                result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
                result.SetStatus (eReturnStatusFailed);
            }
            else
            {
                const char *reg_name = command.GetArgumentAtIndex(0);
                const char *value_str = command.GetArgumentAtIndex(1);
                const RegisterInfo *reg_info = reg_context->GetRegisterInfoByName(reg_name);

                if (reg_info)
                {
                    Scalar scalar;
                    Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size));
                    if (error.Success())
                    {
                        if (reg_context->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar))
                        {
                            result.SetStatus (eReturnStatusSuccessFinishNoResult);
                            return true;
                        }
                    }
                    else
                    {
                        result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
                                                     reg_name,
                                                     value_str,
                                                     error.AsCString());
                        result.SetStatus (eReturnStatusFailed);
                    }
                }
                else
                {
                    result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
                    result.SetStatus (eReturnStatusFailed);
                }
            }
        }
        else
        {
            result.AppendError ("no current frame");
            result.SetStatus (eReturnStatusFailed);
        }
        return result.Succeeded();
    }
开发者ID:eightcien,项目名称:lldb,代码行数:59,代码来源:CommandObjectRegister.cpp

示例6: Cast_

template <typename Int> inline
float Cast_( const Scalar<Int>& s, ScalarType<float,Int> )
{
	switch ( s.Type() ) {
	default: TypeCastError( s.Type(), SINGLE );
	case SINGLE:     return s.template Get_<float>();
	}
}
开发者ID:mcg1969,项目名称:Elemental,代码行数:8,代码来源:scalar_impl.hpp

示例7: Equal

 bool Scalar::Equal( Scalar& a, Scalar& b )
{
    if( a.Type() != b.Type() )
        return false;

    DataType* pA = a.Get();
    DataType* pB = b.Get();

    return DataType::Equal( pA, pB );
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:10,代码来源:Value.cpp

示例8:

void
IM::multiply_assign (const Scalar& s, const Unit& u)
{
  daisy_assert (unit_);
  for (std::map<symbol, double>::iterator i = content.begin (); 
       i != content.end ();
       i++)
    (*i).second = Units::multiply (*unit_, s.unit (),
                                   (*i).second * s.value (), u);
  unit_ = &u;
}
开发者ID:pamoakoy,项目名称:daisy-model,代码行数:11,代码来源:im.C

示例9: value_sp

uint64_t
SBValue::GetValueAsUnsigned(uint64_t fail_value)
{
    ValueLocker locker;
    lldb::ValueObjectSP value_sp(GetSP(locker));
    if (value_sp)
    {
        Scalar scalar;
        if (value_sp->ResolveValue (scalar))
            return scalar.ULongLong(fail_value);
    }
    return fail_value;
}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:13,代码来源:SBValue.cpp

示例10: dolfin_error

//-----------------------------------------------------------------------------
double dolfin::assemble(const Form& a)
{
  if (a.rank() != 0)
  {
    dolfin_error("assemble.cpp",
                 "assemble form",
                 "Expecting a scalar form but rank is %d",
                 a.rank());
  }

  Scalar s;
  Assembler assembler;
  assembler.assemble(s, a);
  return s.get_scalar_value();
}
开发者ID:WeilinDeng,项目名称:dolfin,代码行数:16,代码来源:assemble.cpp

示例11: api_locker

uint64_t
SBValue::GetValueAsUnsigned(uint64_t fail_value)
{
    if (m_opaque_sp)
    {
        if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
        {
            Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
            Scalar scalar;
            if (m_opaque_sp->ResolveValue (scalar))
                return scalar.GetRawBits64(fail_value);
        }
    }
    return fail_value;
}
开发者ID:markpeek,项目名称:lldb,代码行数:15,代码来源:SBValue.cpp

示例12: ReadIntegerArgument

static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width,
                                bool is_signed, Thread &thread,
                                uint32_t *argument_register_ids,
                                unsigned int &current_argument_register,
                                addr_t &current_stack_argument) {
  if (bit_width > 64)
    return false; // Scalar can't hold large integer arguments

  if (current_argument_register < 6) {
    scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
        argument_register_ids[current_argument_register], 0);
    current_argument_register++;
    if (is_signed)
      scalar.SignExtend(bit_width);
  } else {
    uint32_t byte_size = (bit_width + (8 - 1)) / 8;
    Status error;
    if (thread.GetProcess()->ReadScalarIntegerFromMemory(
            current_stack_argument, byte_size, is_signed, scalar, error)) {
      current_stack_argument += byte_size;
      return true;
    }
    return false;
  }
  return true;
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:26,代码来源:ABISysV_ppc64.cpp

示例13: AssignSum

bool Multivector::AssignSum( const Multivector& multivectorA, const Multivector& multivectorB )
{
	if( this == &multivectorA && this == &multivectorB )
	{
		Scalar scalarTwo;
		if( !scalarTwo.Assign( 2.0 ) )
			return false;

		if( !AssignScalarProduct( scalarTwo, *this ) )
			return false;

		return true;
	}
	
	bool accumulateA = true;
	bool accumulateB = true;

	if( this == &multivectorA )
		accumulateA = false;
	else if( this == &multivectorB )
		accumulateB = false;
	else
		sumOfTerms.RemoveAll();

	if( accumulateA )
	{
		for( const SumOfTerms::Node* node = multivectorA.sumOfTerms.Head(); node; node = node->Next() )
		{
			const Term* term = node->data;
			sumOfTerms.InsertAfter()->data = term->Clone();
		}
	}

	if( accumulateB )
	{
		for( const SumOfTerms::Node* node = multivectorB.sumOfTerms.Head(); node; node = node->Next() )
		{
			const Term* term = node->data;
			sumOfTerms.InsertAfter()->data = term->Clone();
		}
	}

	if( !CollectTerms( Term::OUTER_PRODUCT ) )
		return false;

	return true;
}
开发者ID:mapleyustat,项目名称:GACompute,代码行数:47,代码来源:Multivector.cpp

示例14: Scalar

Scalar *TimeAnalysisWidget::addScalar( std::string name ) {
    int index = -1;
    for ( unsigned i = 0; i < _scalars.size(); ++i )
        if ( _scalars[i]->name() == name ) {
            index = i;
            break;
        }

    if ( index == -1 ) {
        Scalar *scalar = new Scalar( name );
        scalar->setIndex(_scalars.size());
        _scalars.push_back( scalar );
        return scalar;
    } else {
        return _scalars[index];
    }
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:17,代码来源:timeanalysiswidget.cpp

示例15: AssignInnerProduct

bool Multivector::AssignInnerProduct( const Multivector& multivectorA, const Multivector& multivectorB )
{
	if( multivectorA.CountProductTypes( Term::GEOMETRIC_PRODUCT ) > 0 )
		if( !const_cast< Multivector* >( &multivectorA )->CollectTerms( Term::OUTER_PRODUCT ) )
			return false;

	if( multivectorB.CountProductTypes( Term::GEOMETRIC_PRODUCT ) > 0 )
		if( !const_cast< Multivector* >( &multivectorB )->CollectTerms( Term::OUTER_PRODUCT ) )
			return false;

	Multivector* multivectorResult = this;

	Multivector multivectorStorage;
	if( this == &multivectorA || this == &multivectorB )
		multivectorResult = &multivectorStorage;

	for( const SumOfTerms::Node* nodeA = multivectorA.sumOfTerms.Head(); nodeA; nodeA = nodeA->Next() )
	{
		const Term* termA = nodeA->data;

		for( const SumOfTerms::Node* nodeB = multivectorB.sumOfTerms.Head(); nodeB; nodeB = nodeB->Next() )
		{
			const Term* termB = nodeB->data;

			Multivector innerProductMultivector;
			if( !termA->InnerProductMultiply( termB, innerProductMultivector ) )
				return false;

			Scalar scalar;
			if( !scalar.AssignProduct( *termA->coeficient, *termB->coeficient ) )
				return false;

			if( !innerProductMultivector.AssignScalarProduct( scalar, innerProductMultivector ) )
				return false;

			multivectorResult->sumOfTerms.Absorb( &innerProductMultivector.sumOfTerms );
		}
	}

	if( multivectorResult == &multivectorStorage )
		return Assign( multivectorStorage );

	return true;
}
开发者ID:mapleyustat,项目名称:GACompute,代码行数:44,代码来源:Multivector.cpp


注:本文中的Scalar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。