Esempio n. 1
0
//Load rocognition model
bool FaceVue::load_Recognition_Model(const string &filename)
{
    ifstream input;
    input.open (filename.c_str());

    if(!input.is_open())
    {
        printf("Recognition params' path is not correct \n");
        return false;
    }
    else
    {
        string str;
        while (getline( input, str))
        {
            if(str.find("binThreshold")!=string::npos){
                stripSpace(str);
                recognition_Model.binThreshold=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
            if(str.find("globalThreshold")!=string::npos){
                stripSpace(str);
                recognition_Model.globalThreshold=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
        }
        input.close();
        return true;
    }
}
Esempio n. 2
0
//Load description model
bool FaceVue::load_Description_Model(const string &filename_params,const string &filename_clusters)
{

    // Reading parameters

    ifstream input;
    input.open(filename_params.c_str());
    if(!input.is_open())
    {
        printf("Parametrs' path is not correct \n");
        return false;
    }
    else
    {
        string str;
        while (getline( input, str))
        {
            if(str.find("m_patch")!=string::npos){
                stripSpace(str);
                description_Model.m_patch=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
            if(str.find("n_patch")!=string::npos){
                stripSpace(str);
                description_Model.n_patch=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
            if(str.find("window")!=string::npos){
                stripSpace(str);
                description_Model.window=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
            if(str.find("K_cluster")!=string::npos){
                stripSpace(str);
                description_Model.K_cluster=atoi(str.substr(str.find_last_of("=")+1,str.length()).c_str());
            }
        }

        input.close();
    }

    // Reading clusters
    description_Model.clusters = new uchar[description_Model.m_patch*description_Model.n_patch*description_Model.K_cluster*59];
    FILE* clu = fopen(filename_clusters.c_str(),"rb");
    if(clu==NULL)
    {
        printf("Clusters' path is not correct \n");
        return false;
    }
    else
    {
        uchar a;
        for(int i=0;i<description_Model.m_patch*description_Model.n_patch*description_Model.K_cluster*59;i++)
        {
            fread(&a, sizeof(uchar), 1, clu);
            description_Model.clusters[i] = (uchar)a;
        }
        fclose(clu);
    }
    return true;
}
Esempio n. 3
0
int main(void)
{
	char *data;
	long m,n;
	printf("%s%c%c\n",
	"Content-Type:text/html;charset=iso-8859-1",13,10);

//	printf("<h3>Multiplication results</h3>\n");

	data = getenv("QUERY_STRING");

  

	stripSpace(data);
	char schemaclass[500];
	char schematype[500];
	char namedvaluearray[500];
	char name[500];
	char value[500];
	char command[500];
	char varcontent[500];
  char jsoncontent[500];
  char NVelement[500];
//  printf("URL %s<BR>\n",data);
  strcpy(command,data);
  unencode(command);
  findVarInURL(varcontent,data,"xplpacket");
  unencode(varcontent); 
  stripSpace(varcontent);
	
  xPL_initialize(xPL_getParsedConnectionType());
  webgateway = xPL_createService("viknet", "webgateway", "default");  
  xPL_setServiceVersion(webgateway, "1.0");

  
  /* Add a responder for time setting */
  xPL_addServiceListener(webgateway, webgatewayMessageHandler, xPL_MESSAGE_ANY, "security", NULL, NULL);
  xPL_setServiceEnabled(webgateway, TRUE);
  /* Create a message to send */
  xplMessage = xPL_createBroadcastMessage(webgateway, xPL_MESSAGE_COMMAND);

  if (JSONfindObject(schemaclass,varcontent,"msgschemaclass")!=NULL && JSONfindObject(schematype,varcontent,"msgschematype")!=NULL)
    xPL_setSchema(xplMessage, JSONtoString(schemaclass), JSONtoString(schematype));
	else
    xPL_setSchema(xplMessage, "schemaclass", "schematype");	
	
	JSONfindObject(namedvaluearray,varcontent,"namevaluelist");
  int i;
   for (i=0;i<JSONArrayLength(namedvaluearray);i++)
   {
     JSONArrayAt(NVelement,namedvaluearray,i);
	   if ( JSONfindObject(name,NVelement,"name") && JSONfindObject(value,NVelement,"value"))
	   xPL_addMessageNamedValue(xplMessage, JSONtoString(name), JSONtoString(value));	   
   }
   xPL_sendMessage(xplMessage);
//   xPL_processMessages(0);
	return 0;  
}       
Esempio n. 4
0
void Query::execute( Connector *conn, string s_query)
{

	this->connector = conn;
	this->query = s_query;
	this->execute();

	logger->debug("connector: %p, executing query: %s\n", conn, s_query.c_str());

	if (!this->getStatus()){
		logger->debug("Query failed.\n ");
	} else {
		logger->debug("fetching results..\n");
		fetch_results(); 
		bind_variables();// allocating and binding variables for iteration
		vector<field>::iterator iter_f = v_fields.begin();
#ifdef MSSQL
		while (dbnextrow(conn->conn_ptr) != NO_MORE_ROWS){
			iter_f = v_fields.begin();
			while(iter_f!=v_fields.end()){
				if(iter_f->type!=field::TYPE_INT)
					stripSpace(iter_f->data, iter_f->size);
				iter_f++;
			}
			num_records++;
			iterate(v_fields);
		}
#endif
#ifdef WATCHLIST_MYSQL
		if (res != NULL){// insert or update queries.
			this->num_records = mysql_num_rows(res);
			MYSQL_ROW row;
			int pos;
			if (res !=NULL && (num_records > 0))
			while( ( row = mysql_fetch_row(res))){
				// fetch each records
				pos = 0;
				iter_f = v_fields.begin();
				while(iter_f!=v_fields.end()){
					// iterating columns
					if (iter_f->type==field::TYPE_INT){
						iter_f->setData(atoi(row[pos]));
					} else {
						iter_f->setData(string(row[pos]));
					}
					pos++;
					iter_f++;
				}
				iterate(v_fields);// passing to child
			}
			mysql_free_result(res);
		} 
#endif
	}

	logger->debug("completed execute\n");
}
Esempio n. 5
0
HostCoreConf * readConf( HostCoreConf * hc_conf )
{
	const char * labels[] =
	{
		"Quick Key",
		"IP",
		"Port",
		"Password",
		"Connection",
		"Block Size",
	};
	const int items_count = 6;
	char buf[128];
	int fd = sceIoOpen( CONF_FILE, PSP_O_RDONLY, 0644 );
	memset( hc_conf, 0, sizeof( HostCoreConf ) );
	if ( fd >= 0 )
	{
		while( readLine( fd, buf, 128 ) >= 0 )
		{
			stripSpace( buf );
			if ( buf[0] == '#' || buf[0] == 0 )
				continue;
			int i;
			for ( i = 0; i < items_count; i ++ )
			{
				if ( !strncmp( labels[i], buf, strlen( labels[i] ) ) )
				{
					char * start = strchr( buf, '"' );
					if ( !start )
						continue;
					char * end = strchr( start + 1, '"' );
					if ( !end )
						continue;
					*end = 0;
					if ( strlen( start + 1 ) < 16 )
						strcpy( ( char * )hc_conf + ( 16 * i ), start + 1 );
				}
			}
		}
		sceIoClose( fd );
	}
	else
	{
		log( "Error opening conf\n" );
	}
	if ( hc_conf->key[0] == 0 )
		strcpy( hc_conf->key, "800000" );
	if ( hc_conf->ip[0] == 0 )
		strcpy( hc_conf->ip, "192.168.0.1" );
	if ( hc_conf->port[0] == 0 )
		strcpy( hc_conf->port, "7513" );
	if ( hc_conf->entry[0] == 0 )
		strcpy( hc_conf->entry, "1" );
	if ( hc_conf->entry[0] == 0 )
		strcpy( hc_conf->blocksize, "2048" );
	return hc_conf;
}