예제 #1
0
int main (int argc, char * const argv[]) {
    JSONExport::COLLADA2JSONContext converterArgs;
    
    printf("Collada2JSON [pre-alpha] 0.1\n");
    if (__SetupCOLLADA2JSONContext( argc, argv, &converterArgs)) {
#if !STDOUT_OUTPUT
        FILE* fd = fopen(converterArgs.outputFilePath.c_str(), "w");
        if (fd) {
            FileStream s(fd);
#else
            FileStream s(stdout);
#endif
            PrettyWriter <FileStream> jsonWriter(s);
            printf("converting:%s ...\n",converterArgs.inputFilePath.c_str());
            JSONExport::DAE2JSONWriter* writer = new JSONExport::DAE2JSONWriter(converterArgs, &jsonWriter);
            writer->write();
            printf("[completed conversion]\n");
#if !STDOUT_OUTPUT
            fclose(fd);
            delete writer;
        }   
#endif
    }
    return 0;
}
//* For RTConnHttp
void CRTConnection::OnLogin(const char* pUserid, const char* pPass, const char* pNname)
{
    bool ok = false;
    {
        //check & auth
#if 0
        std::string pass;
        RTHiredisRemote::Instance().CmdGet(pUserid, pass);
        if (pass.compare(pPass)!=0) {
            LE("OnLogin pass not same redis error\n");
            return;
        }
#endif
        m_userId = pUserid;
        m_token = pPass;
        m_nname = pNname;
    }
    //if (ok) {
    if (false) {
        std::string sid;
        //store userid & pass
        CRTConnManager::ConnectionInfo* pci = new CRTConnManager::ConnectionInfo();
        if (pci) {
            GenericSessionId(sid);
            m_connectorId = CRTConnManager::Instance().ConnectorId();
            pci->_connId = sid;
            pci->_connAddr = CRTConnManager::Instance().ConnectorIp();
            pci->_connPort = CRTConnManager::Instance().ConnectorPort();
            pci->_userId = pUserid;
            pci->_token = pPass;
            pci->_pConn = NULL;
            pci->_connType = CONNECTIONTYPE::_chttp;
            pci->_flag = 1;
            std::string uid(pUserid);
            CRTConnManager::Instance().AddUser(CONNECTIONTYPE::_chttp, uid, pci);
        } else {
            LE("new ConnectionInfo error!!!\n");
        }
    } else {
        std::string uid(pUserid);
        CRTConnManager::ConnectionInfo* pci = NULL;
        CRTConnManager::Instance().AddUser(CONNECTIONTYPE::_chttp, uid, pci);
    }
    {
        // send response
        rapidjson::Document     jsonDoc;
        rapidjson::StringBuffer jsonStr;
        rapidjson::Writer<rapidjson::StringBuffer>   jsonWriter(jsonStr);
        jsonDoc.SetObject();
        if (ok) {
            jsonDoc.AddMember("login", "success", jsonDoc.GetAllocator());
        } else {
            jsonDoc.AddMember("login", "failed", jsonDoc.GetAllocator());
        }
        jsonDoc.Accept(jsonWriter);
        SendResponse(HPS_OK, jsonStr.GetString());
    }
}
예제 #3
0
// Computes a hash of everything in the scene except the renderer settings
// This is done by serializing everything to JSON and hashing the resulting string
static uint64 sceneHash(Scene &scene)
{
    rapidjson::Document document;
    document.SetObject();
    *(static_cast<rapidjson::Value *>(&document)) = scene.toJson(document.GetAllocator());
    document.RemoveMember("renderer");

    rapidjson::GenericStringBuffer<rapidjson::UTF8<>> buffer;
    rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>> jsonWriter(buffer);
    document.Accept(jsonWriter);

    return BitManip::hash(buffer.GetString());
}
예제 #4
0
파일: main.cpp 프로젝트: hschamberlin/glTF
int main (int argc, char * const argv[]) {
    GLTF::GLTFConverterContext converterContext;
    
    if (processArgs(argc, argv, &converterContext)) {
        if (converterContext.inputFilePath.length() == 0) {
            return -1;
        }
        const char* inputFilePathCStr = converterContext.inputFilePath.c_str();
        
        if (!fileExists(converterContext.inputFilePath.c_str())) {
            printf("path:%s does not exists or is not accessible, please check file path and permissions\n",inputFilePathCStr);
            return -1;
        }
        
        clock_t start = clock();

#if !STDOUT_OUTPUT
        FILE* fd = fopen(converterContext.outputFilePath.c_str(), "w");
        if (fd) {
            rapidjson::FileStream s(fd);
#else
            rapidjson::FileStream s(stdout);
#endif
            rapidjson::PrettyWriter <rapidjson::FileStream> jsonWriter(s);
            if (converterContext.outputProgress) {
                printf("convertion 0%%");
                printf("\n\033[F\033[J");
            } else {
                printf("converting:%s ... as %s \n",converterContext.inputFilePath.c_str(), converterContext.outputFilePath.c_str());
            }
            GLTF::COLLADA2GLTFWriter* writer = new GLTF::COLLADA2GLTFWriter(converterContext, &jsonWriter);
            writer->write();
            if (converterContext.outputProgress) {
                printf("convertion 100%%");
                printf("\n");
            } else {
                printf("[completed conversion]\n");
            }
#if !STDOUT_OUTPUT
            fclose(fd);
            delete writer;
        }
#endif

        std::stringstream s;
        s << std::setiosflags(std::ios::fixed) << std::setprecision(2) << float(clock() - start) / CLK_TCK;
        std::cout << "Runtime: " << s.str() << " seconds" << std::endl;
    }
    return 0;
}
예제 #5
0
			void Show(bool teamChat)
			{
				rapidjson::StringBuffer jsonBuffer;
				rapidjson::Writer<rapidjson::StringBuffer> jsonWriter(jsonBuffer);

				jsonWriter.StartObject();
				jsonWriter.Key("teamChat");
				jsonWriter.Bool(teamChat);
				jsonWriter.Key("captureInput");
				jsonWriter.Bool(true);
				jsonWriter.EndObject();

				ScreenLayer::Show("chat", jsonBuffer.GetString());
			}
        bool RequestActionReturnableLongPolling_GetZoneMediaList::executeActionLongPolling()
        {
            auto id = getOptionValue("id");   
            std::vector<std::shared_ptr<Raumkernel::Media::Item::MediaItem>> mediaList;

            rapidjson::StringBuffer jsonStringBuffer;
            rapidjson::Writer<rapidjson::StringBuffer> jsonWriter(jsonStringBuffer);

            jsonWriter.StartArray();


            // if we got an id we get the list 
            if (!id.empty())
            {
                auto mediaRenderer = getVirtualMediaRenderer(id);
                if (!mediaRenderer)
                {
                    logError("Room or Zone with ID: " + id + " not found!", CURRENT_FUNCTION);
                    return false;
                }                
                std::string zonePlaylistId = Raumkernel::Manager::LISTID_ZONEIDENTIFIER + mediaRenderer->getUDN();                                
                // zone playlists do not have to be extra read, they are always up to date! 
                // So we do only get a copy of the list with shared pointers to media items
                mediaList = managerEngineer->getMediaListManager()->getList(zonePlaylistId);                          

                // add the list items to the jsonWriter
                // we do not have to lock when we are reading the copied list of the media items because they are shared pointers 
                // and media items only will be created once and will never be updated!
                addMediaListToJson(mediaRenderer->getUDN(), mediaList, jsonWriter);
            }
            // if we have no id provided, then we get the playlist for all virtual renderers
            else
            {
                auto zoneInfoMap = getManagerEngineer()->getZoneManager()->getZoneInformationMap();
                for (auto it : zoneInfoMap)
                {
                    std::string zonePlaylistId = Raumkernel::Manager::LISTID_ZONEIDENTIFIER + it.second.UDN;                                     
                    mediaList = managerEngineer->getMediaListManager()->getList(zonePlaylistId);

                    addMediaListToJson(it.second.UDN, mediaList, jsonWriter);
                }
            }            
                                   
            jsonWriter.EndArray();

            setResponseData(jsonStringBuffer.GetString());

            return true;            
        }
void CRTConnection::OnLogout(const char* pUserid)
{
    {
        //logout
        std::string uid(pUserid);
        std::string token;
        CRTConnManager::Instance().DelUser(CONNECTIONTYPE::_chttp, uid, token);
        m_userId = "";
        m_token = "";
        m_nname = "";
    }
    {
        //send response
        rapidjson::Document       jsonDoc;
        rapidjson::StringBuffer   jsonStr;
        rapidjson::Writer<rapidjson::StringBuffer> jsonWriter(jsonStr);
        jsonDoc.SetObject();
        jsonDoc.AddMember("logout", "success", jsonDoc.GetAllocator());
        jsonDoc.Accept(jsonWriter);
        SendResponse(HPS_OK, jsonStr.GetString());
    }
}
void CRTConnection::OnGetMsg(const char* pUserid, int mType)
{
    if (!pUserid) {
        LE("%s invalid params\n", __FUNCTION__);
        SendResponse(HPS_BAD_REQUEST, "");
        return;
    }
    {
        //get msg
        RTTcp::UpdateTimer();
    }
    {
        //send back to user
        rapidjson::Document      jsonDoc;
        rapidjson::StringBuffer  jsonStr;
        rapidjson::Writer<rapidjson::StringBuffer>   jsonWriter(jsonStr);
        jsonDoc.SetObject();

        jsonDoc.AddMember("getmsg", "success", jsonDoc.GetAllocator());
        jsonDoc.Accept(jsonWriter);
        SendResponse(HPS_OK, jsonStr.GetString());
    }
}
예제 #9
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
std::string ChTrackTestRig::ExportComponentList() const {
    rapidjson::Document jsonDocument;
    jsonDocument.SetObject();

    std::string template_name = GetTemplateName();
    jsonDocument.AddMember("name", rapidjson::StringRef(m_name.c_str()), jsonDocument.GetAllocator());
    jsonDocument.AddMember("template", rapidjson::Value(template_name.c_str(), jsonDocument.GetAllocator()).Move(),
                           jsonDocument.GetAllocator());

    {
        rapidjson::Document jsonSubDocument(&jsonDocument.GetAllocator());
        jsonSubDocument.SetObject();
        m_chassis->ExportComponentList(jsonSubDocument);
        jsonDocument.AddMember("chassis", jsonSubDocument, jsonDocument.GetAllocator());
    }

    //// TODO

    rapidjson::StringBuffer jsonBuffer;
    rapidjson::PrettyWriter<rapidjson::StringBuffer> jsonWriter(jsonBuffer);
    jsonDocument.Accept(jsonWriter);

    return jsonBuffer.GetString();
}
std::string NFCMasterNet_ServerModule::GetServersStatus()
{
	rapidjson::Document doc;
	rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
	rapidjson::Value root(rapidjson::kObjectType);

	root.AddMember("code", 0, allocator);
	root.AddMember("errMsg", "", allocator);
	root.AddMember("nowTime", pPluginManager->GetNowTime(), allocator);

	rapidjson::Value master(rapidjson::kArrayType);
	std::shared_ptr<ServerData> pServerData = mMasterMap.First();
	while (pServerData)
	{
		rapidjson::Value server(rapidjson::kObjectType);
		server.AddMember("serverId", pServerData->pData->server_id(), allocator);
		server.AddMember("servrName", rapidjson::Value(pServerData->pData->server_name().c_str(), allocator), allocator);
		server.AddMember("ip", rapidjson::Value(pServerData->pData->server_ip().c_str(), allocator), allocator);
		server.AddMember("port", pServerData->pData->server_port(), allocator);
		server.AddMember("onlineCount", pServerData->pData->server_cur_count(), allocator);
		server.AddMember("status", (int)pServerData->pData->server_state(), allocator);
		/*
		rapidjson::Value server_info_ext(rapidjson::kArrayType);
		for (int i = 0; i < pServerData->pData->server_info_list_ext().key_size();i++)
		{
			rapidjson::Value extKeyValue(rapidjson::kObjectType);
			extKeyValue.AddMember(rapidjson::Value(pServerData->pData->server_info_list_ext().key(i).c_str(), allocator), rapidjson::Value(pServerData->pData->server_info_list_ext().value(i).c_str(), allocator), allocator);
			server_info_ext.PushBack(extKeyValue, allocator);
		}
		server.AddMember("info_ext", server_info_ext, allocator);
		*/
		master.PushBack(server, allocator);
		pServerData = mMasterMap.Next();
	}
	root.AddMember("master", master, allocator);

	rapidjson::Value logins(rapidjson::kArrayType);
	pServerData = mLoginMap.First();
	while (pServerData)
	{
		rapidjson::Value server(rapidjson::kObjectType);
		server.AddMember("serverId", pServerData->pData->server_id(), allocator);
		server.AddMember("servrName", rapidjson::Value(pServerData->pData->server_name().c_str(), allocator), allocator);
		server.AddMember("ip", rapidjson::Value(pServerData->pData->server_ip().c_str(), allocator), allocator);
		server.AddMember("port", pServerData->pData->server_port(), allocator);
		server.AddMember("onlineCount", pServerData->pData->server_cur_count(), allocator);
		server.AddMember("status", (int)pServerData->pData->server_state(), allocator);
		/*
		rapidjson::Value server_info_ext(rapidjson::kArrayType);
		for (int i = 0; i < pServerData->pData->server_info_list_ext().key_size();i++)
		{
			rapidjson::Value extKeyValue(rapidjson::kObjectType);
			extKeyValue.AddMember(rapidjson::Value(pServerData->pData->server_info_list_ext().key(i).c_str(), allocator), rapidjson::Value(pServerData->pData->server_info_list_ext().value(i).c_str(), allocator), allocator);
			server_info_ext.PushBack(extKeyValue, allocator);
		}
		server.AddMember("info_ext", server_info_ext, allocator);
		*/
		logins.PushBack(server, allocator);
		pServerData = mLoginMap.Next();
	}
	root.AddMember("logins", logins, allocator);

	rapidjson::Value worlds(rapidjson::kArrayType);
	pServerData = mWorldMap.First();
	while (pServerData.get())
	{
		rapidjson::Value server(rapidjson::kObjectType);
		server.AddMember("serverId", pServerData->pData->server_id(), allocator);
		server.AddMember("servrName", rapidjson::Value(pServerData->pData->server_name().c_str(), allocator), allocator);
		server.AddMember("ip", rapidjson::Value(pServerData->pData->server_ip().c_str(), allocator), allocator);
		server.AddMember("port", pServerData->pData->server_port(), allocator);
		server.AddMember("onlineCount", pServerData->pData->server_cur_count(), allocator);
		server.AddMember("status", (int)pServerData->pData->server_state(), allocator);
		/*
		rapidjson::Value server_info_ext(rapidjson::kArrayType);
		for (int i = 0; i < pServerData->pData->server_info_list_ext().key_size();i++)
		{
			rapidjson::Value extKeyValue(rapidjson::kObjectType);
			extKeyValue.AddMember(rapidjson::Value(pServerData->pData->server_info_list_ext().key(i).c_str(), allocator), rapidjson::Value(pServerData->pData->server_info_list_ext().value(i).c_str(), allocator), allocator);
			server_info_ext.PushBack(extKeyValue, allocator);
		}
		server.AddMember("info_ext", server_info_ext, allocator);
		*/
		worlds.PushBack(server, allocator);
		pServerData = mWorldMap.Next();
	}
	root.AddMember("worlds", worlds, allocator);

	rapidjson::Value proxys(rapidjson::kArrayType);
	pServerData = mProxyMap.First();
	while (pServerData.get())
	{
		rapidjson::Value server(rapidjson::kObjectType);
		server.AddMember("serverId", pServerData->pData->server_id(), allocator);
		server.AddMember("servrName", rapidjson::Value(pServerData->pData->server_name().c_str(), allocator), allocator);
		server.AddMember("ip", rapidjson::Value(pServerData->pData->server_ip().c_str(), allocator), allocator);
		server.AddMember("port", pServerData->pData->server_port(), allocator);
		server.AddMember("onlineCount", pServerData->pData->server_cur_count(), allocator);
		server.AddMember("status", (int)pServerData->pData->server_state(), allocator);

		/*
		rapidjson::Value server_info_ext(rapidjson::kArrayType);
		for (int i = 0; i < pServerData->pData->server_info_list_ext().key_size();i++)
		{
			rapidjson::Value extKeyValue(rapidjson::kObjectType);
			extKeyValue.AddMember(rapidjson::Value(pServerData->pData->server_info_list_ext().key(i).c_str(), allocator), rapidjson::Value(pServerData->pData->server_info_list_ext().value(i).c_str(), allocator), allocator);
			server_info_ext.PushBack(extKeyValue, allocator);
		}
		server.AddMember("info_ext", server_info_ext, allocator);
		*/
		proxys.PushBack(server, allocator);
		pServerData = mProxyMap.Next();
	}
	root.AddMember("proxys", proxys, allocator);

	rapidjson::Value games(rapidjson::kArrayType);
	pServerData = mGameMap.First();
	while (pServerData.get())
	{
		rapidjson::Value server(rapidjson::kObjectType);
		server.AddMember("serverId", pServerData->pData->server_id(), allocator);
		server.AddMember("servrName", rapidjson::Value(pServerData->pData->server_name().c_str(), allocator), allocator);
		server.AddMember("ip", rapidjson::Value(pServerData->pData->server_ip().c_str(), allocator), allocator);
		server.AddMember("port", pServerData->pData->server_port(), allocator);
		server.AddMember("onlineCount", pServerData->pData->server_cur_count(), allocator);
		server.AddMember("status", (int)pServerData->pData->server_state(), allocator);
		/*
		rapidjson::Value server_info_ext(rapidjson::kArrayType);
		for (int i = 0; i < pServerData->pData->server_info_list_ext().key_size();i++)
		{
			rapidjson::Value extKeyValue(rapidjson::kObjectType);
			extKeyValue.AddMember(rapidjson::Value(pServerData->pData->server_info_list_ext().key(i).c_str(), allocator), rapidjson::Value(pServerData->pData->server_info_list_ext().value(i).c_str(), allocator), allocator);
			server_info_ext.PushBack(extKeyValue, allocator);
		}
		server.AddMember("info_ext", server_info_ext, allocator);
		*/
		games.PushBack(server, allocator);
		pServerData = mGameMap.Next();
	}
	root.AddMember("games", games, allocator);

	rapidjson::StringBuffer jsonBuf;
	rapidjson::Writer<rapidjson::StringBuffer> jsonWriter(jsonBuf);
	root.Accept(jsonWriter);
	return jsonBuf.GetString();
}
void MultipleDatasetComparisonSecondExperiment::runExperiment(std::string outputDir)
{
	// Set up the image filters
	DownsampleFilter dsf(64, 64);	// Dataset images are in a 1:1 ratio.
	GreyscaleFilter gf;
	std::list<ImageFilterInterface*> filters;
	filters.push_back(&dsf);
	filters.push_back(&gf);

	// Load the reference dataset
	std::unique_ptr<CachedDataset> referenceDataset = loadDataset(
		MultipleDatasetComparisonSecondExperiment::TIME_OF_DAY_NOON,
		MultipleDatasetComparisonSecondExperiment::PASS_BASELINE,
		filters);
	std::cout << "Loaded reference dataset... (" << referenceDataset->count() << " images)" << std::endl;

	// Set up the place recognition object, salience mask generator, and output image
	PlaceRecognition placerecog;
	SumOfAbsoluteDifferencesMatcher sadMatcher;
	cv::Mat diagonalMatrix;
	float performance;

	// Create a RapidJson document to write the results into.
	rapidjson::Document results(rapidjson::kObjectType);

	// Set some standard criteria for considering two images to have a 'similar' location
	SimilarityCriteria similarityCriteria(300.0);

	// For each test time of day, for each pass through, measure the performance
	// This will match the reference set against itself
	for (int timeOfDay = MultipleDatasetComparisonSecondExperiment::TIME_OF_DAY_DAWN;
	timeOfDay <= MultipleDatasetComparisonSecondExperiment::TIME_OF_DAY_SUNSET; ++timeOfDay)
	{
		std::string timeOfDayString = getTimeOfDayString(timeOfDay);
		rapidjson::Value nestedResults(rapidjson::kObjectType);

		for (int pass = MultipleDatasetComparisonSecondExperiment::PASS_FIRST;
		pass <= MultipleDatasetComparisonSecondExperiment::PASS_LAST; ++pass)
		{
			std::string passString = getPassString(pass);
			std::unique_ptr<CachedDataset> queryDataset = loadDataset(timeOfDay, pass, filters);
			std::cout << "Loaded test dataset \"" << timeOfDayString << "\" subset \"" << passString << "\" (" << queryDataset->count() << " images)" << std::endl;

			performance = placerecog.generateDiagonalMatrix(*referenceDataset, *queryDataset, sadMatcher, similarityCriteria, diagonalMatrix);
			writeFloatImage(outputDir + "\\diagonal matrix " + timeOfDayString + " " + passString + ".png", diagonalMatrix);
			std::cout << "Matching accuracy for " << timeOfDayString << " " << passString << ": " << (performance * 100) << "%" << std::endl;

			nestedResults.AddMember(
				rapidjson::Value(passString.c_str(), results.GetAllocator()).Move(),
				performance,
				results.GetAllocator());
		}

		results.AddMember(
			rapidjson::Value(timeOfDayString.c_str(), results.GetAllocator()).Move(),
			nestedResults,
			results.GetAllocator());
	}

	// Serialze the json output.
	rapidjson::StringBuffer jsonBuffer;
	rapidjson::PrettyWriter<rapidjson::StringBuffer> jsonWriter(jsonBuffer);
	results.Accept(jsonWriter);

	// Write the json file to a string
	std::ofstream output(outputDir + "\\multiple comparison results.txt");
	output << jsonBuffer.GetString();
	output.close();
}