示例#1
0
void BackGround::GetBackground_One_pass( string srcfilename,string outputdir,unsigned int width,unsigned int height, cv::Size win_stride)
{
	Init(width,height);
	LoadPictures(srcfilename);
	SetOutputDir(outputdir);

	string filepath;
	ifstream fin(m_srcfilename.c_str(),ios_base::in);
	if(!fin.is_open())
	{
#ifdef DEBUG_OUTPUT
		cout<<"Open File Error"<<endl;
#endif
		exit(1);
	}
	cv::Mat tmpimg;
	while(getline(fin,filepath))
	{
		m_input.release();
		tmpimg=cv::imread(filepath,0);
		cv::copyMakeBorder(tmpimg,m_input,40,40,40,40,cv::BORDER_REPLICATE);
		SetPrefix(GetFileName(filepath.c_str()));
		OutputBackground_OnePass(win_stride);
	}
	fin.close();
}
示例#2
0
void CLR_RT_HeapBlock_XmlNode::Clear()
{
    CLR_RT_HeapBlock_String* empty = CLR_RT_HeapBlock_String::GetStringEmpty();

    SetName        ( empty );
    SetNamespaceURI( empty );
    SetPrefix      ( empty );
    SetLocalName   ( empty );
    ClearFlags     (       );
}
示例#3
0
CpuTemperature::CpuTemperature(uint8_t nSensor): RDMSensor(nSensor) {
	SetType(E120_SENS_TEMPERATURE);
	SetUnit(E120_UNITS_CENTIGRADE);
	SetPrefix(E120_PREFIX_NONE);
	SetRangeMin(RDM_SENSOR_TEMPERATURE_ABS_ZERO);
	SetRangeMax(RDM_SENSOR_RANGE_MAX);
	SetNormalMin(RDM_SENSOR_TEMPERATURE_ABS_ZERO);
	SetNormalMax((int16_t) Hardware::Get()->GetCoreTemperatureMax());
	SetDescription("CPU");
}
示例#4
0
文件: keys.c 项目: GreenLunar/smaFS
/* Create and store the master secret see page 32, 6.1 */
int MakeMasterSecret(SSL* ssl)
{
    byte   shaOutput[SHA_DIGEST_SIZE];
    byte   md5Input[ENCRYPT_LEN + SHA_DIGEST_SIZE];
    byte   shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN];
    int    i;
    word32 idx;
    word32 pmsSz = ssl->arrays.preMasterSz;

    Md5 md5;
    Sha sha;

#ifndef NO_TLS
    if (ssl->options.tls) return MakeTlsMasterSecret(ssl);
#endif

    InitMd5(&md5);
    InitSha(&sha);

    memcpy(md5Input, ssl->arrays.preMasterSecret, pmsSz);

    for (i = 0; i < MASTER_ROUNDS; ++i) {
        byte prefix[PREFIX];
        if (!SetPrefix(prefix, i)) {
            return PREFIX_ERROR;
        }

        idx = 0;
        memcpy(shaInput, prefix, i + 1);
        idx += i + 1;

        memcpy(shaInput + idx, ssl->arrays.preMasterSecret, pmsSz);
        idx += pmsSz;
        memcpy(shaInput + idx, ssl->arrays.clientRandom, RAN_LEN);
        idx += RAN_LEN;
        memcpy(shaInput + idx, ssl->arrays.serverRandom, RAN_LEN);
        idx += RAN_LEN;
        ShaUpdate(&sha, shaInput, idx);
        ShaFinal(&sha, shaOutput);

        idx = pmsSz;  /* preSz */
        memcpy(md5Input + idx, shaOutput, SHA_DIGEST_SIZE);
        idx += SHA_DIGEST_SIZE;
        Md5Update(&md5, md5Input, idx);
        Md5Final(&md5, &ssl->arrays.masterSecret[i * MD5_DIGEST_SIZE]);
    }
    DeriveKeys(ssl);

    CleanPreMaster(ssl);

    return 0;
}
SensorSI7021Humidity::SensorSI7021Humidity(uint8_t nSensor, uint8_t nAddress): RDMSensor(nSensor) {
	SetType(E120_SENS_HUMIDITY);
	SetUnit(E120_UNITS_NONE);
	SetPrefix(E120_PREFIX_NONE);
	SetRangeMin(0);
	SetRangeMax(100);
	SetNormalMin(RDM_SENSOR_RANGE_MIN);
	SetNormalMax(RDM_SENSOR_RANGE_MAX);
	SetDescription("Relative Humidity");

	memset(&sDeviceInfo, 0, sizeof(struct _device_info));
	sDeviceInfo.slave_address = nAddress;
}
void FdoSmLpGrdPropertyMappingSingle::SetupOverrides( 
	const FdoSmLpPropertyMappingSingle* pBase,
	FdoSmLpObjectPropertyDefinition* pParent, 
    FdoRdbmsOvPropertyMappingSingle* pOverrides,
    bool bInherit
)
{
    FdoSmPhMgrP mgr = GetLogicalPhysicalSchema()->GetPhysicalSchema();
    FdoStringP prefix = GetPrefix();

    // Extract the physical overrides.
    if ( pOverrides ) {
         prefix = pOverrides->GetPrefix();

         if ( prefix.GetLength() > 0 ) {
            if ( prefix != mgr->CensorDbObjectName(prefix) )
                AddPrefixCharError(prefix);

            if ( prefix.GetLength() > mgr->DbObjectNameMaxLen() ) 
                AddPrefixLengthError(prefix, mgr->DbObjectNameMaxLen());
         }
    }

    if ( prefix.GetLength() == 0 ) {
        if ( pBase ) {
            // Get them from base definition if this one is copied or inherited.
            prefix = pBase->GetPrefix();
        }

        // Generate default column prefix from object property name.
        if ( prefix.GetLength() == 0 ) {
            prefix = mgr->CensorDbObjectName(pParent->GetName()).Mid(0,25);
        }

        if ( (pParent->GetElementState() == FdoSchemaElementState_Added) && !bInherit ) {
            FdoSmLpObjectPropertyClass* pParentClass = 
                dynamic_cast<FdoSmLpObjectPropertyClass*>( (FdoSmLpSchemaElement*)(pParent->GetParent()) );
            // Pre-pend base property prefix to keep prefix as unique as possible.
            if ( pParentClass ) {
                const FdoSmLpPropertyMappingSingle* pParentMapping = 
                    FdoSmLpGrdPropertyMappingSingle::Cast( pParentClass->RefObjectProperty()->RefMappingDefinition() );

                if ( pParentMapping ) {
                    prefix = FdoStringP(pParentMapping->GetPrefix()) + L"_" + prefix;
                }
            }
        }
    }

    SetPrefix( prefix );
}
示例#7
0
文件: keys.c 项目: agoragames/cyassl
int DeriveKeys(SSL* ssl)
{
    int length = 2 * ssl->specs.hash_size + 
                 2 * ssl->specs.key_size  +
                 2 * ssl->specs.iv_size;
    int rounds = (length + MD5_DIGEST_SIZE - 1 ) / MD5_DIGEST_SIZE, i;

    byte shaOutput[SHA_DIGEST_SIZE];
    byte md5Input[SECRET_LEN + SHA_DIGEST_SIZE];
    byte shaInput[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN];
  
    Md5 md5;
    Sha sha;

    byte keyData[KEY_PREFIX * MD5_DIGEST_SIZE];  /* max size */

    InitMd5(&md5);
    InitSha(&sha);

    XMEMCPY(md5Input, ssl->arrays.masterSecret, SECRET_LEN);

    for (i = 0; i < rounds; ++i) {
        int j   = i + 1;
        int idx = j;

        if (!SetPrefix(shaInput, i)) {
            return PREFIX_ERROR;
        }

        XMEMCPY(shaInput + idx, ssl->arrays.masterSecret, SECRET_LEN);
        idx += SECRET_LEN;
        XMEMCPY(shaInput + idx, ssl->arrays.serverRandom, RAN_LEN);
        idx += RAN_LEN;
        XMEMCPY(shaInput + idx, ssl->arrays.clientRandom, RAN_LEN);
        idx += RAN_LEN;

        ShaUpdate(&sha, shaInput, sizeof(shaInput) - KEY_PREFIX + j);
        ShaFinal(&sha, shaOutput);

        XMEMCPY(&md5Input[SECRET_LEN], shaOutput, SHA_DIGEST_SIZE);
        Md5Update(&md5, md5Input, sizeof(md5Input));
        Md5Final(&md5, keyData + i * MD5_DIGEST_SIZE);
    }

    return StoreKeys(ssl, keyData);
}
void SavingThread::run()
{
    PvResult lResult = PvResult::Code::NOT_CONNECTED;

    try
    {
        assert( mDevice != NULL );
        assert( mStream != NULL );
        assert( mDlg != NULL );

        if ( ( mSetupDlg->GetRole() == SetupDlg::RoleCtrlData ) ||
             ( mSetupDlg->GetRole() == SetupDlg::RoleCtrl ) ||
             ( mSetupDlg->GetRole() == SetupDlg::RoleMonitor ) )
        {
            mDlg->SetStatus( "Saving the device parameters..." );

            SetPrefix( tr( "Device state save error. " ) );
            lResult = mWriter->Store( mDevice );
            if ( !lResult.IsOK() )
            {
                mResult = lResult.GetCode();
                return;
            }
        }

        if ( ( mSetupDlg->GetRole() == SetupDlg::RoleCtrlData ) ||
            ( mSetupDlg->GetRole() == SetupDlg::RoleData ) )
        {
            mDlg->SetStatus( "Saving the stream parameters..." );

            lResult = mWriter->Store( mStream );
            if ( !lResult.IsOK() )
            {
                mResult = lResult.GetCode();
                return;
            }
        }
    }
    catch ( ... )
    {
        lResult = PvResult::Code::ABORTED;
    }

    mResult = lResult.GetCode();
    return;
}
示例#9
0
void MERGE::SignalSource::ParseParameters()
{
    SourceParametersT params = GetSourceParameters();

    if (params.size() != Parameters::SOURCE_PARAM_N)
    {
        throw std::runtime_error("Invalid number of source parameters: " + m_SourceDescription);
    }
    else
    {
        SetFormat(params[Parameters::LOG_FORMAT]);
        SetSyncPoint(params[Parameters::SYNC_POINT]);
        SetTimeUnit(params[Parameters::TIME_UNIT]);
        SetPrefix(params[Parameters::PREFIX]);
        SetCounterName(params[Parameters::LINE_COUNTER]);
        SetFilename(params[Parameters::FILENAME]);
    }
}
示例#10
0
void BackGround::GetBackground(string srcfilename,string outputdir,unsigned int width,unsigned int height,double scale,double scalefactor,double step)
{
	Init(width,height);
	LoadPictures(srcfilename);
	SetOutputDir(outputdir);

	string filepath;
	ifstream fin(m_srcfilename.c_str(),ios_base::in);
	if(!fin.is_open())
	{
#ifdef DEBUG_OUTPUT
		cout<<"Open File Error"<<endl;
#endif
		exit(1);
	}
	while(getline(fin,filepath))
	{
		m_input.release();
		m_input=cv::imread(filepath,0);
		SetPrefix(GetFileName(filepath.c_str()));
		OutputBackground(scale,scalefactor,step);
	}
	fin.close();
}
示例#11
0
文件: keys.c 项目: agoragames/cyassl
/* Create and store the master secret see page 32, 6.1 */
int MakeMasterSecret(SSL* ssl)
{
    byte   shaOutput[SHA_DIGEST_SIZE];
    byte   md5Input[ENCRYPT_LEN + SHA_DIGEST_SIZE];
    byte   shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN];
    int    i, ret;
    word32 idx;
    word32 pmsSz = ssl->arrays.preMasterSz;

    Md5 md5;
    Sha sha;

#ifdef SHOW_SECRETS
    {
        int j;
        printf("pre master secret: ");
        for (j = 0; j < pmsSz; j++)
            printf("%02x", ssl->arrays.preMasterSecret[j]);
        printf("\n");
    }
#endif

#ifndef NO_TLS
    if (ssl->options.tls) return MakeTlsMasterSecret(ssl);
#endif

    InitMd5(&md5);
    InitSha(&sha);

    XMEMCPY(md5Input, ssl->arrays.preMasterSecret, pmsSz);

    for (i = 0; i < MASTER_ROUNDS; ++i) {
        byte prefix[PREFIX];
        if (!SetPrefix(prefix, i)) {
            return PREFIX_ERROR;
        }

        idx = 0;
        XMEMCPY(shaInput, prefix, i + 1);
        idx += i + 1;

        XMEMCPY(shaInput + idx, ssl->arrays.preMasterSecret, pmsSz);
        idx += pmsSz;
        XMEMCPY(shaInput + idx, ssl->arrays.clientRandom, RAN_LEN);
        idx += RAN_LEN;
        XMEMCPY(shaInput + idx, ssl->arrays.serverRandom, RAN_LEN);
        idx += RAN_LEN;
        ShaUpdate(&sha, shaInput, idx);
        ShaFinal(&sha, shaOutput);

        idx = pmsSz;  /* preSz */
        XMEMCPY(md5Input + idx, shaOutput, SHA_DIGEST_SIZE);
        idx += SHA_DIGEST_SIZE;
        Md5Update(&md5, md5Input, idx);
        Md5Final(&md5, &ssl->arrays.masterSecret[i * MD5_DIGEST_SIZE]);
    }

#ifdef SHOW_SECRETS
    {
        int i;
        printf("master secret: ");
        for (i = 0; i < SECRET_LEN; i++)
            printf("%02x", ssl->arrays.masterSecret[i]);
        printf("\n");
    }
#endif

    ret = DeriveKeys(ssl);
    CleanPreMaster(ssl);

    return ret;
}
示例#12
0
CChunksEvent::CChunksEvent(const CMultiPartFrameCollection& aFrameCollection, MEventOutputHandler& aOutputHandler)
    : CTraceEventBase(aFrameCollection, aOutputHandler)
    {
    SetPrefix("EChunks");
    }
示例#13
0
CChunksEvent::CChunksEvent(const CUTraceFrame& aFrame, MEventOutputHandler& aOutputHandler)
    : CTraceEventBase(aFrame, aOutputHandler)
    {
    SetPrefix("EChunks");
    }
示例#14
0
 void XMLNode::StripNamespace(int recursion) {
   SetPrefix(node_, NULL, recursion);
 }