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


C++ FileReader类代码示例

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


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

示例1: ex_qrs_hr_features

bool ex_qrs_hr_features(void *args) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/ecg");
	reader->getOptions()->block = 0.2;
	ITransformable *ecg_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	// qrs detection
	QRSDetection *ecg_chain = ssi_create(QRSDetection, 0, true);
	ecg_chain->getOptions()->sendEvent = false;
	ITransformable *ecg_qrs_t = frame->AddTransformer(ecg_p, ecg_chain, "0.75s", "0", "60.0s");

	// heart rate
	QRSHeartRate *qrshr = ssi_create(QRSHeartRate, 0, true);
	ITransformable *ecg_hr_t = frame->AddTransformer(ecg_qrs_t, qrshr, "1.0s", "0", "60.0s");

	// heart rate features
	Spectrogram *spectogram = ssi_create(Spectrogram, 0, true);
	ssi_strcpy(spectogram->getOptions()->file, "hrspect.banks");
	spectogram->getOptions()->nbanks = 3;
	ITransformable *ecg_hr_spec_t = frame->AddTransformer(ecg_hr_t, spectogram, "1", "29", "60.0s");

	//hrv_spectral
	QRSHRVspectral *ecg_hr_spectralfeatures = ssi_create(QRSHRVspectral, 0, true);
	ecg_hr_spectralfeatures->getOptions()->print = true;
	ITransformable *ecg_hr_spectralfeatures_t = frame->AddTransformer(ecg_hr_spec_t, ecg_hr_spectralfeatures, "1", "0", "60.0s");

	//hrv_time
	QRSHRVtime *ecg_hr_timefeatures = ssi_create(QRSHRVtime, 0, true);
	ecg_hr_timefeatures->getOptions()->print = true;
	ITransformable *ecg_hr_timefeatures_t = frame->AddTransformer(ecg_qrs_t, ecg_hr_timefeatures, "1.0s", "6.5s", "60.0s");

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 100.0f;

	//qrs
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_qrs_t, plot, "0.75s");

	//heart rate
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("hr");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_hr_t, plot, "1");

	//spectrgram
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("hr spect");
	plot->getOptions()->size = p_size;
	plot->getOptions()->type = PaintSignalType::IMAGE;
	frame->AddConsumer(ecg_hr_spec_t, plot, "1");

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:81,代码来源:Main.cpp

示例2: ProcessDemoFile

	bool ProcessDemoFile(const char* filePath)
	{
		for(u32 i = 0; i < ID_MAX_CLIENTS; ++i)
		{
			_players[i].Name.clear();
			_players[i].Valid = false;
		}

		FileReader reader;
		if(!reader.Open(filePath))
		{
			return false;
		}

		udtCuContext* const cuContext = _cuContext;
		const u32 protocol = udtGetProtocolByFilePath(filePath);
		const s32 firstPlayerIdx = udtGetIdConfigStringIndex((u32)udtConfigStringIndex::FirstPlayer, protocol);
		if(firstPlayerIdx < 0)
		{
			PrintError("Failed to get the first index of player config strings");
			return false;
		}

		_protocol = (udtProtocol::Id)protocol;
		_protocolFirstPlayerCsIdx = firstPlayerIdx;

		s32 errorCode = udtCuStartParsing(cuContext, protocol);
		if(errorCode != udtErrorCode::None)
		{
			PrintError("udtCuStartParsing failed: %s", udtGetErrorCodeString(errorCode));
			return false;
		}

		udtCuMessageInput input;
		udtCuMessageOutput output;
		u32 continueParsing = 0;
		for(;;)
		{
			if(!reader.Read(&input.MessageSequence, 4))
			{
				PrintWarning("Demo is truncated");
				return true;
			}

			if(!reader.Read(&input.BufferByteCount, 4))
			{
				PrintWarning("Demo is truncated");
				return true;
			}

			if(input.MessageSequence == -1 &&
			   input.BufferByteCount == u32(-1))
			{
				// End of demo file.
				break;
			}

			if(input.BufferByteCount > ID_MAX_MSG_LENGTH)
			{
				PrintError("Corrupt input: the buffer length exceeds the maximum allowed");
				return false;
			}

			if(!reader.Read(_inMsgData, input.BufferByteCount))
			{
				PrintWarning("Demo is truncated");
				return true;
			}
			input.Buffer = _inMsgData;

			errorCode = udtCuParseMessage(cuContext, &output, &continueParsing, &input);
			if(errorCode != udtErrorCode::None)
			{
				PrintError("udtCuParseMessage failed: %s", udtGetErrorCodeString(errorCode));
				return false;
			}

			if(continueParsing == 0)
			{
				break;
			}

			AnalyzeMessage(output);
		}

		return true;
	}
开发者ID:Bumbadawg,项目名称:uberdemotools,代码行数:87,代码来源:tut_players.cpp

示例3: if

void
WorldObjRenderer::process(const FileReader& reader)
{
  // FIXME: does not handle sprite alignment
  // FIXME: does not handle remove groundpieces
  // FIXME: does not handle liquid
  if (reader.get_name() == "surface-background" ||
      reader.get_name() == "starfield-background" ||
      reader.get_name() == "solidcolor-background" ||
      reader.get_name() == "snow-generator" ||
      reader.get_name() == "rain-generator")
  {
    // ignore
  }
  else if (reader.get_name() == "groundpiece" ||
           reader.get_name() == "liquid" ||
           reader.get_name() == "exit" ||
           reader.get_name() == "hotspot")
  {
    process_object_with_surface(reader);
  }
  else if (reader.get_name() == "entrance")
  {
    Vector3f pos;
    reader.read_vector("position", pos);
    render_sprite(ResDescriptor("entrances/generic"), pos);
  }
  else if (reader.get_name() == "spike")
  {
    Vector3f pos;
    reader.read_vector("position", pos);
    render_surface(ResDescriptor("traps/spike_editor"), pos);
  }
  else if (reader.get_name() == "switchdoor-switch")
  {
    Vector3f pos;
    reader.read_vector("position", pos);
    render_surface(ResDescriptor("worldobjs/switchdoor_switch"), pos);
  }
  else if (reader.get_name() == "switchdoor-door")
  {
    Vector3f pos;
    reader.read_vector("position", pos);
    render_surface(ResDescriptor("worldobjs/switchdoor_box"), pos);
  }
  else if (reader.get_name() == "group")
  {
    FileReader objects = reader.read_section("objects");
    process(objects.get_sections());
  }
  else if (reader.get_name() == "prefab")
  {
    std::string name;
    if (!reader.read_string("name", name))
    {
      log_error("'name' tag missing for prefab");
    }
    else
    {
      PrefabFile prefab = PrefabFile::from_resource(name);

      Vector3f position;
      reader.read_vector("position", position);
      push_translate(static_cast<int>(position.x),
                     static_cast<int>(position.y));
      process(prefab.get_objects());
      pop_translate();
    }
  }
  else
  {
    log_error("unknown object type: %1%", reader.get_name());
  }
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:74,代码来源:worldobj_renderer.cpp

示例4: BenchmarkDArray

void BenchmarkDArray(Sorter<char *> &sorter)
{
	DArray<char *> data, rdata;
	Stopwatch sw;
	char buffer[512], format[64];
	sprintf(format, "%s", "%4.3lfs");

	FileReader file;

	file.SetLineEndings(CC_LN_LF);
	file.Open("dataset");

	if (file.IsOpen()) {
		data.setStepDouble();
		rdata.setStepDouble();

		console->Write("Loading... ");

		sw.Start();

		/* Load the file into the data DArray */
		while (file.ReadLine(buffer, sizeof(buffer)) >= 0)
			data.insert(cc_strdup(buffer));

		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		file.Close();

		console->WriteLine("Loaded %d items.", data.used());

		console->Write("Random: ");
		sw.Start();
		data.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		/* Create a reverse-sorted DArray */
		for (long i = (long)data.size(); i >= 0; i--) {
			if (data.valid(i)) {
				rdata.insert(data.get(i));
			}
		}

		console->Write("Pre-sorted: ");
		sw.Start();
		data.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		console->Write("Reverse-sorted: ");
		sw.Start();
		rdata.sort(sorter);
		sw.Stop();
		console->WriteLine(format, sw.Elapsed());

		for (size_t i = 0; i < data.size(); i++) {
			if (data.valid(i)) {
				free(data.get(i));
				data.remove(i);
			}
		}

		data.empty();
		rdata.empty();
	} else {
		console->WriteLine("Dataset not found.");
	}
}
开发者ID:prophile,项目名称:crisscross,代码行数:69,代码来源:main.cpp

示例5:

Options
Options::from_file_reader(const FileReader& reader)
{
  Options opts;

  int int_value;
  bool bool_value;
  std::string string_value;
  Size size_value;

  FramebufferType fbtype_value = SDL_FRAMEBUFFER;

  if (reader.read_enum("renderer", fbtype_value, framebuffer_type_from_string))
  {
    opts.framebuffer_type.set(fbtype_value);
  }

  if (reader.read_int("master-volume", int_value)) 
  {
    opts.master_volume.set(int_value);
  }
  
  if (reader.read_int("sound-volume", int_value))
  {
    opts.sound_volume.set(int_value);
  }
  
  if (reader.read_int("music-volume", int_value))
  {
    opts.music_volume.set(int_value);
  }

  if (reader.read_size("geometry", size_value))
  {
    opts.geometry.set(size_value);
  }
  
  if (reader.read_size("fullscreen-resolution", size_value))
  {
    opts.fullscreen_resolution.set(size_value);
  }

  if (reader.read_bool("fullscreen", bool_value))
  {
    opts.fullscreen.set(bool_value);
  }
  
  if (reader.read_bool("resizable", bool_value))
  {
    opts.resizable.set(bool_value);
  }

  if (reader.read_bool("mouse-grab", bool_value))
  {
    opts.mouse_grab.set(bool_value);
  }
  
  if (reader.read_bool("print-fps", bool_value))
  {
    opts.mouse_grab.set(bool_value);
  }

  if (reader.read_string("controller", string_value))
  {
    opts.controller.set(string_value);
  }

  if (reader.read_string("language", string_value))
  {
    opts.language.set(string_value);
  }
  
  if (reader.read_bool("software-cursor", bool_value))
  {
    opts.software_cursor.set(bool_value);
  }
  
  if (reader.read_bool("auto-scrolling", bool_value))
  {
    opts.auto_scrolling.set(bool_value);
  }

  if (reader.read_bool("drag-drop-scrolling", bool_value))
  {
    opts.drag_drop_scrolling.set(bool_value);
  }

  return opts;
}
开发者ID:AMDmi3,项目名称:pingus,代码行数:89,代码来源:options.cpp

示例6: ex_framework

bool ex_framework (void *arg) {

	TheFramework *frame = ssi_pcast (TheFramework, Factory::GetFramework ());
	//frame->getOptions ()->monitor = true;
	//frame->getOptions ()->setMonitorPos (800, 0, 400, 200);
	//frame->getOptions ()->console = true;
	//frame->getOptions ()->setConsolePos (800, 200, 400, 200);
	//ThePainter *painter = ssi_pcast (ThePainter, Factory::GetPainter ());

	double sample_rate = 200.0;
	double frequency = 5.0;
	double sine_len = 60.0;
	double plot_dur = 11.1;
	const ssi_char_t *print_dur = "1.0s";
	double provide_size = 0.1;
	bool repeat = true;

	unsigned int len = static_cast<unsigned int> (sample_rate * sine_len);
	double *data = new double [len];
	data[0] = 0.0;
	double delta = 1/sample_rate;
	for (unsigned int i = 1; i < len; i++) {
		data[i] = data[i-1] + delta;
	}
	for (unsigned int i = 0; i < len; i++) {
		data[i] = sin (2.0 * PI * frequency * data[i]);
	}

	//Provider::SetLogLevel (SSI_LOG_LEVEL_DEBUG);
	//Transformer::SetLogLevel (SSI_LOG_LEVEL_DEBUG);
	//Consumer::SetLogLevel (SSI_LOG_LEVEL_DEBUG);
	frame->SetLogLevel (SSI_LOG_LEVEL_DEBUG);

	FileReader *simulator = ssi_create (FileReader, 0, true);
	simulator->getOptions ()->setPath ("input");
	simulator->getOptions ()->loop = true;
	simulator->getOptions ()->block = provide_size;
	ITransformable *provider = frame->AddProvider (simulator, SSI_FILEREADER_PROVIDER_NAME);
	//simulator.setLogLevel (SSI_LOG_LEVEL_DEBUG);
	frame->AddSensor (simulator);

	AbsFilt<float> abs;
	RampFilt<float> ramp;
	IFilter *filter[2] = {&abs, &ramp};
	MeanFeat<float> mean;
	MinMaxFeat<float> minmax;
	IFeature *feature[2] = {&mean, &minmax};

	//Chain chain (2, filter, 2, feature);
	Chain *chain = ssi_create (Chain, 0, true);
	chain->set (2, filter, 2, feature);
	ITransformable *chain_t = frame->AddTransformer (provider, chain, "0.05s", "0.05s");

	MyConsumer my_consumer_;
	//Chain chain_2 (2, filter, 2, feature);
	Chain *chain_2 = ssi_create (Chain, 0, true);
	chain_2->set (2, filter, 2, feature);
	frame->AddConsumer (provider, &my_consumer_, "0.05s", "0.05s", chain_2);

/*
	SignalPainter *signal_painter = ssi_create (SignalPainter, 0, true);
	signal_painter->getOptions ()->setName ("signal");
	signal_painter->getOptions ()->size = plot_dur;
	frame->AddConsumer (provider, signal_painter, "0.1s");

	SignalPainter *chain_painter = ssi_create (SignalPainter, 0, true);
	chain_painter->getOptions ()->setName ("chain");
	chain_painter->getOptions ()->size = plot_dur;
	frame->AddConsumer (chain_t, chain_painter, "0.1s");
*/
	FileWriter *signal_printer = ssi_create (FileWriter, 0, true);
	signal_printer->getOptions ()->type = File::ASCII;
	signal_printer->getOptions ()->setPath ("signal.txt");
	frame->AddConsumer (provider, signal_printer, print_dur);

	FileWriter *signal_bprinter = ssi_create (FileWriter, 0, true);
	signal_bprinter->getOptions ()->setPath ("signal.dat");
	frame->AddConsumer (provider, signal_bprinter, print_dur);

	FileWriter *chain_printer = ssi_create (FileWriter, 0, true);
	chain_printer->getOptions ()->type = File::ASCII;
	chain_printer->getOptions ()->setPath ("chain.txt");
	frame->AddConsumer (chain_t, chain_printer, print_dur);

	FileWriter *chain_bprinter = ssi_create (FileWriter, 0, true);
	chain_bprinter->getOptions ()->setPath ("chain.dat");
	frame->AddConsumer (chain_t, chain_bprinter, print_dur);

	frame->Start ();
	//painter->Arrange (1, 2, 0, 0, 800, 400);
	frame->Wait ();
	frame->Stop ();
	frame->Clear ();
	//painter->Clear ();

	delete[] data;

	return true;
}
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:99,代码来源:Main_.cpp

示例7: main

int main(int argc, char* argv[]) {

  // parse flags
  gflags::SetUsageMessage("This script builds a database for a given dataset of vectors\n"
        "Usage:\n"
        "    tool_createdb --c1 4 --c2 4 --p 2 --basename \"tmp\""
        " You should convert the fvecs beforehand using the accompanying convert script\n");
  gflags::SetVersionString("1.0.0");
  gflags::ParseCommandLineFlags(&argc, &argv, true);

  // select cuda device
  cudaSetDevice(FLAGS_device);
  cudaSetDeviceFlags (cudaDeviceMapHost);

  const string preName  = FLAGS_basename + "_" + std::to_string(FLAGS_dim) + "_" + std::to_string(FLAGS_p)
                        + "_" + std::to_string(FLAGS_c1) + "_" + std::to_string(FLAGS_c2);


  // read in dataset
  FileReader<float> DataReader = FileReader<float>(FLAGS_dataset);
  EXPECT_EQ((uint) FLAGS_dim, DataReader.dim());
  arr<float> data((int) FLAGS_chunksize * FLAGS_dim);
  data.mallocHost();
  data.mallocDevice();
  data.host = DataReader.data(FLAGS_chunksize);
  data.toDevice();

  // building the codebook
  // ==============================================================================================
  int k = 16;
  PerturbationProTree ppt(FLAGS_dim, FLAGS_p, FLAGS_p);
  const string codebook_file = preName + ".ppqt";

  ppt.createTree(FLAGS_c1, FLAGS_c2, data.device, 20000);
  ppt.writeTreeToFile(codebook_file);

  

  const string lineName   = preName + "_" + std::to_string(FLAGS_lineparts) + ".lines";
  const string prefixName = preName + ".prefix";
  const string countsName = preName + ".count";
  const string dbIdxName  = preName + ".dbIdx";

  const uint chunkMax = DataReader.num() / FLAGS_chunksize;
  const uint data_num = chunkMax * FLAGS_chunksize;

  uint* binPrefix = new uint[FLAGS_hashsize];
  uint* binCounts = new uint[FLAGS_hashsize];
  uint* dbIdx = new uint[data_num];

  // building the data base
  // ==============================================================================================
  uint* dbIdxSave = new uint[data_num];

  memset(binPrefix, 0, FLAGS_hashsize * sizeof(uint));
  memset(binCounts, 0, FLAGS_hashsize * sizeof(uint));
  memset(dbIdx, 0, data_num * sizeof(uint));

  uint* chBinPrefix = new uint[FLAGS_hashsize];
  uint* chBinCounts = new uint[FLAGS_hashsize];
  uint* chDBIdx     = new uint[FLAGS_chunksize];
  float* chLines    = new float[FLAGS_chunksize * FLAGS_lineparts];


  ppt.buildKBestDB(data.device, FLAGS_chunksize);
  ppt.lineDist(data.device, FLAGS_chunksize);

  // GPU -> CPU memory
  SAFE_CUDA_CALL(cudaMemcpy(chBinPrefix, ppt.getBinPrefix(), FLAGS_hashsize * sizeof(uint),  cudaMemcpyDeviceToHost));
  SAFE_CUDA_CALL(cudaMemcpy(chBinCounts, ppt.getBinCounts(), FLAGS_hashsize * sizeof(uint),  cudaMemcpyDeviceToHost));
  SAFE_CUDA_CALL(cudaMemcpy(chDBIdx,     ppt.getDBIdx(),     FLAGS_chunksize * sizeof(uint), cudaMemcpyDeviceToHost));
  SAFE_CUDA_CALL(cudaMemcpy(chLines,     ppt.getLine(),      FLAGS_chunksize * FLAGS_lineparts * sizeof(float), cudaMemcpyDeviceToHost));

  ofstream fLines(lineName.c_str(), std::ofstream::out | std::ofstream::binary);
  fLines.write((char*) chLines, FLAGS_chunksize * FLAGS_lineparts * sizeof(float));
  fLines.close();
  cout << "written " << lineName << endl;

  // prefixSum for bin-idx
  ofstream fprefix(prefixName.c_str(), std::ofstream::out | std::ofstream::binary);
  fprefix.write((char*) binPrefix, FLAGS_hashsize * sizeof(uint));
  fprefix.close();
  cout << "written " << prefixName << endl;

  // size of non-empty bins
  ofstream fcounts(countsName.c_str(), std::ofstream::out | std::ofstream::binary);
  fcounts.write((char*) binCounts, FLAGS_hashsize * sizeof(uint));
  fcounts.close();
  cout << "written " << countsName << endl;
  cout << "size: " << (FLAGS_hashsize * sizeof(uint)) << endl;

  // for each bin the ids of containing vectors
  ofstream fdb(dbIdxName.c_str(), std::ofstream::out | std::ofstream::binary);
  fdb.write((char*) dbIdx, data_num * sizeof(uint));
  fdb.close();
  cout << "written " << dbIdxName << endl;

  if (data.device)
    cudaFree(data.device);
  delete[] data.host;
//.........这里部分代码省略.........
开发者ID:ZhouZhenkun,项目名称:Product-Quantization-Tree,代码行数:101,代码来源:tool_createdb.cpp

示例8: main

int main(int argc, char* argv[]) {

  // parse flags
  gflags::SetUsageMessage("This script builds a database for a given dataset of vectors\n"
                          "Usage:\n"
                          "    tool_createdb --c1 4 --c2 4 --p 2 --basename \"tmp\""
                          " You should convert the fvecs beforehand using the accompanying convert script\n");
  gflags::SetVersionString("1.0.0");
  gflags::ParseCommandLineFlags(&argc, &argv, true);

  // select cuda device
  cudaSetDevice(FLAGS_device);
  cudaSetDeviceFlags (cudaDeviceMapHost);

  const string preName  = FLAGS_basename + "_" + std::to_string(FLAGS_dim) + "_" + std::to_string(FLAGS_p)
                          + "_" + std::to_string(FLAGS_c1) + "_" + std::to_string(FLAGS_c2);


  FileReader<float> DataReader = FileReader<float>(FLAGS_dataset);

  FileReader<float> QueryReader = FileReader<float>(FLAGS_queryset);
  EXPECT_EQ((uint) FLAGS_dim, QueryReader.dim());
  arr<float> query = arr<float>(FLAGS_chunksize * FLAGS_dim);
  query.mallocHost();
  query.mallocDevice();
  query.host = QueryReader.data(FLAGS_chunksize);
  query.toDevice();


  PerturbationProTree ppt(FLAGS_dim, FLAGS_p, FLAGS_p);
  const string codebook_file = preName + ".ppqt";

  if (!file_exists(codebook_file)) {
    cout << "you need to generate a codebook first. No codebook found in " << codebook_file << endl;
    return 1;
  } else {
    cout << "codebook exists, reading from " << codebook_file << endl;
    ppt.readTreeFromFile(codebook_file);
  }

  const uint base_num = DataReader.num();

  const string lineName   = preName + "_" + std::to_string(FLAGS_lineparts) + ".lines";
  const string prefixName = preName + ".prefix";
  const string countsName = preName + ".count";
  const string dbIdxName  = preName + ".dbIdx";

  const uint chunkMax = base_num / FLAGS_chunksize;
  const uint data_num = chunkMax * FLAGS_chunksize;

  uint* binPrefix = new uint[FLAGS_hashsize];
  uint* binCounts = new uint[FLAGS_hashsize];
  uint* dbIdx     = new uint[data_num];

  // read data base
  ifstream fprefix(prefixName.c_str(), std::ifstream::in | std::ofstream::binary);
  fprefix.read((char*) binPrefix, FLAGS_hashsize * sizeof(uint));
  fprefix.close();
  cout << "read " << prefixName << endl;

  ifstream fcounts(countsName.c_str(), std::ofstream::in | std::ofstream::binary);
  fcounts.read((char*) binCounts, HASH_SIZE * sizeof(uint));
  fcounts.close();
  cout << "read " << countsName << endl;

  size_t nfloats = DataReader.num();
  nfloats *= FLAGS_lineparts;

  float* hLines = nullptr;
  float* dLines;

  cudaHostAlloc((void **) &hLines, nfloats * sizeof(float), cudaHostAllocMapped);
  cudaHostGetDevicePointer((void **) &dLines, (void *) hLines, 0);
  if (!hLines) {
    cerr << " did not get hLine memory " << endl;
    exit(1);
  }

  ifstream fdb(dbIdxName.c_str(), std::ifstream::in | std::ofstream::binary);
  fdb.read((char*) dbIdx, base_num * sizeof(uint));
  fdb.close();
  cout << "read " << dbIdxName << endl;


  ppt.setDB(base_num, binPrefix, binCounts, dbIdx);

  // query
  vector<uint> resIdx;
  vector<float> resDist;
  
  for (int idxA = 0; idxA < FLAGS_chunksize; idxA += 4096) {
    const int len = min(4096, (int)(FLAGS_chunksize - idxA));
    ppt.queryKNN(resIdx, resDist, query.device + 4096 * idxA * FLAGS_dim, len, 4096);
    for (int r = 0; r < len; ++r) {
      const int queryVectorId = idxA*4096 + r;
      const int bestfoundBaseVectorId = resIdx[4096*r];
      const int secondbestfoundBaseVectorId = resIdx[4096*r+1];
    }
  }

//.........这里部分代码省略.........
开发者ID:ZhouZhenkun,项目名称:Product-Quantization-Tree,代码行数:101,代码来源:tool_query.cpp

示例9: load

void SimpleFileSystemVolume::load(FileReader& file)
{
    auto lock = ScopedMutexLock(mutex_);

    file.readPointerVector(entries_);
}
开发者ID:savant-nz,项目名称:carbon,代码行数:6,代码来源:SimpleFileSystemVolume.cpp

示例10: ex_gsr_baseline_mean

bool ex_gsr_baseline_mean(void *args) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/gsr");
	reader->getOptions()->block = 0.2;
	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	//lowpass
	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->low = 0.01;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	lowpass->getOptions()->zero = true;
	ITransformable *gsr_low_t = frame->AddTransformer(gsr_p, lowpass, "0.25s");

	//detrend
	GSRRemoveBaseline *detrend = ssi_create(GSRRemoveBaseline, 0, true);
	ITransformable *gsr_detrend_t = frame->AddTransformer(gsr_low_t, detrend, "0.25s");

	//norm
	MvgNorm *norm = ssi_create(MvgNorm, 0, true);
	norm->getOptions()->norm = MvgNorm::SUBMIN;
	norm->getOptions()->method = MvgNorm::SLIDING;
	norm->getOptions()->win = 15.0;
	ITransformable *gsr_detrend_norm_t = frame->AddTransformer(gsr_detrend_t, norm, "0.25s");

	GSRBaselineMean *mean = ssi_create(GSRBaselineMean, 0, true);
	mean->getOptions()->winsize = 15.0;
	frame->AddConsumer(gsr_detrend_norm_t, mean, "0.25s");
	board->RegisterSender(*mean);

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 100.0f;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_low_t, plot, "0.3s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(detrended)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_detrend_t, plot, "0.3s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(detrended & normed)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_detrend_norm_t, plot, "0.3s");

	//events
	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, mean->getEventAddress());

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:80,代码来源:Main.cpp

示例11: ex_qrs_hrv_event

bool ex_qrs_hrv_event(void *args) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/ecg");
	reader->getOptions()->block = 0.2;
	ITransformable *ecg_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	//bandpass
	Butfilt *ecg_band = ssi_create(Butfilt, 0, true);
	ecg_band->getOptions()->type = Butfilt::BAND;
	ecg_band->getOptions()->norm = false;
	ecg_band->getOptions()->high = 15;
	ecg_band->getOptions()->low = 5;
	ecg_band->getOptions()->order = 13;
	ITransformable *ecg_band_t = frame->AddTransformer(ecg_p, ecg_band, "0.75s");

	//diff
	Derivative *ecg_diff = ssi_create(Derivative, 0, true);
	ssi_strcpy(ecg_diff->getOptions()->names, "1st");
	ITransformable *ecg_diff_t = frame->AddTransformer(ecg_band_t, ecg_diff, "0.75s");

	//qrs-pre-process
	QRSPreProcess *ecg_QRSpre = ssi_create(QRSPreProcess, 0, true);
	ITransformable *ecg_QRSpre_t = frame->AddTransformer(ecg_diff_t, ecg_QRSpre, "0.75s");

	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->zero = true;
	lowpass->getOptions()->norm = false;
	lowpass->getOptions()->low = 6.4;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	ITransformable *ecg_QRSpre_low_t = frame->AddTransformer(ecg_QRSpre_t, lowpass, "0.75s");

	//qrs-detect
	QRSDetect *ecg_qrs = ssi_create(QRSDetect, 0, true);
	ecg_qrs->getOptions()->sendEvent = true;
	ITransformable *ecg_qrs_t = frame->AddTransformer(ecg_QRSpre_low_t, ecg_qrs, "0.75s");
	board->RegisterSender(*ecg_qrs);

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 10.0f;
	//raw
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("raw");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_p, plot, "0.2s");
	//bandpass
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("bandpass");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_band_t, plot, "0.2s");
	//diff
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("diff");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_diff_t, plot, "0.2s");
	//qrs-pre
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs-pre");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_QRSpre_low_t, plot, "0.2s");
	//qrs
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_qrs_t, plot, "0.2s");

	//events
	QRSHrvEventListener *hrv = ssi_create(QRSHrvEventListener, 0, true);
	hrv->getOptions()->span = 120000;
	hrv->getOptions()->update_ms = 5000;
	board->RegisterListener(*hrv, ecg_qrs->getEventAddress(), 10000);
	board->RegisterSender(*hrv);

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, hrv->getEventAddress(), 10000);

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();
//.........这里部分代码省略.........
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:101,代码来源:Main.cpp

示例12: ex_gsr_peaks_online

bool ex_gsr_peaks_online(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\gsr");
	reader->getOptions()->block = 0.2;
	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->low = 0.01;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	lowpass->getOptions()->zero = true;
	ITransformable *gsr_low = frame->AddTransformer(gsr_p, lowpass, "0.2s");

	GSREventSender *gsr_event = ssi_create(GSREventSender, 0, true);
	gsr_event->getOptions()->tuple = true;
	gsr_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);
	frame->AddConsumer(gsr_low, gsr_event, "4.0s");
	board->RegisterSender(*gsr_event);

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, gsr_event->getEventAddress());

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_p, plot, "0.2s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_low, plot, "0.2s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("peak");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "[email protected]");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("slope");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "[email protected]");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("drop");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "[email protected]");

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:71,代码来源:Main.cpp

示例13: ex_bvp_beat_events_raw

bool ex_bvp_beat_events_raw(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\bvp");
	reader->getOptions()->block = 0.2;
	reader->getOptions()->loop = false;

	ITransformable *bvp_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("bvp");
	plot->getOptions()->size = 10.0;
	frame->AddConsumer(bvp_p, plot, "1");

	BVPBeatEventSender *bvp_event = ssi_create(BVPBeatEventSender, 0, true);
	bvp_event->getOptions()->beep = true;
	bvp_event->getOptions()->mean_window = 1;
	bvp_event->getOptions()->tuple = true;

	bvp_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);

	frame->AddConsumer(bvp_p, bvp_event, "0.2s");

	board->RegisterSender(*bvp_event);

	BVPBeatEventRawListener *event_listener = ssi_create(BVPBeatEventRawListener, 0, true);
	event_listener->getOptions()->sr = 9;

	ITransformable *heartRate = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_HEART_RATE_PROVIDER_NAME);
	ITransformable *amp = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_AMPLITUDE_PROVIDER_NAME);
	ITransformable *interBeat = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_INTERBEAT_INTERVAL_PROVIDER_NAME);

	frame->AddSensor(event_listener);

	board->RegisterListener(*event_listener, bvp_event->getEventAddress());

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("heartRate");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(heartRate, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("amp");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(amp, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("interBeat");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(interBeat, plot, "1");

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, bvp_event->getEventAddress());

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:77,代码来源:Main.cpp

示例14: ex_gsr_response_amplitude_events

bool ex_gsr_response_amplitude_events(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\gsr");
	reader->getOptions()->block = 0.2;
	reader->getOptions()->loop = false;

	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_p, plot, "1");

	GSRResponseEventSender *gsr_event = ssi_create(GSRResponseEventSender, 0, true);
	gsr_event->getOptions()->tuple = true;
	gsr_event->getOptions()->minRisingTime = 0;
	gsr_event->getOptions()->minAllowedRegression = 0.1f;
	gsr_event->getOptions()->minAmplitude = 0.5f;
	gsr_event->getOptions()->print = false;

	gsr_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);

	frame->AddConsumer(gsr_p, gsr_event, "0.2s");

	board->RegisterSender(*gsr_event);

	GSREventListener *event_listener = ssi_create(GSREventListener, 0, true);
	event_listener->getOptions()->statisticalFn = GSR_SUM;
	event_listener->getOptions()->window = SSI_GSR_EVENTLISTENER_NO_WINDOW;

	ITransformable *nr_of_responses = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_NUMBER_OF_RESPONSES_PROVIDER_NAME);
	ITransformable *amp = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_AMPLITUDE_PROVIDER_NAME);
	ITransformable *power = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_POWER_PROVIDER_NAME);

	frame->AddSensor(event_listener);

	board->RegisterListener(*event_listener, gsr_event->getEventAddress());

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("nr_of_responses");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(nr_of_responses, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("amp");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(amp, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("power");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(power, plot, "1");

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, gsr_event->getEventAddress());

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;

}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:81,代码来源:Main.cpp

示例15: FWadLump

void FPNGTexture::MakeTexture ()
{
	FileReader *lump;

	if (SourceLump >= 0)
	{
		lump = new FWadLump(Wads.OpenLumpNum(SourceLump));
	}
	else
	{
		lump = new FileReader(SourceFile.GetChars());
	}

	Pixels = new BYTE[Width*Height];
	if (StartOfIDAT == 0)
	{
		memset (Pixels, 0x99, Width*Height);
	}
	else
	{
		DWORD len, id;
		lump->Seek (StartOfIDAT, SEEK_SET);
		lump->Read(&len, 4);
		lump->Read(&id, 4);

		if (ColorType == 0 || ColorType == 3)	/* Grayscale and paletted */
		{
			M_ReadIDAT (lump, Pixels, Width, Height, Width, BitDepth, ColorType, Interlace, BigLong((unsigned int)len));

			if (Width == Height)
			{
				if (PaletteMap != NULL)
				{
					FlipSquareBlockRemap (Pixels, Width, Height, PaletteMap);
				}
				else
				{
					FlipSquareBlock (Pixels, Width, Height);
				}
			}
			else
			{
				BYTE *newpix = new BYTE[Width*Height];
				if (PaletteMap != NULL)
				{
					FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap);
				}
				else
				{
					FlipNonSquareBlock (newpix, Pixels, Width, Height, Width);
				}
				BYTE *oldpix = Pixels;
				Pixels = newpix;
				delete[] oldpix;
			}
		}
		else		/* RGB and/or Alpha present */
		{
			int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4;
			BYTE *tempix = new BYTE[Width * Height * bytesPerPixel];
			BYTE *in, *out;
			int x, y, pitch, backstep;

			M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len));
			in = tempix;
			out = Pixels;

			// Convert from source format to paletted, column-major.
			// Formats with alpha maps are reduced to only 1 bit of alpha.
			switch (ColorType)
			{
			case 2:		// RGB
				pitch = Width * 3;
				backstep = Height * pitch - 3;
				for (x = Width; x > 0; --x)
				{
					for (y = Height; y > 0; --y)
					{
						if (!HaveTrans)
						{
							*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
						}
						else
						{
							if (in[0] == NonPaletteTrans[0] &&
								in[1] == NonPaletteTrans[1] &&
								in[2] == NonPaletteTrans[2])
							{
								*out++ = 0;
							}
							else
							{
								*out++ = RGB32k.RGB[in[0]>>3][in[1]>>3][in[2]>>3];
							}
						}
						in += pitch;
					}
					in -= backstep;
				}
				break;
//.........这里部分代码省略.........
开发者ID:Accusedbold,项目名称:zdoom,代码行数:101,代码来源:pngtexture.cpp


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