Exemplo n.º 1
0
SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
	: Control(engine, key, CONTROL_SAFE) {
	_statesCount = 0;
	_curState = 0;
	_animation = NULL;
	_innerRaduis = 0;
	_innerRadiusSqr = 0;
	_outerRadius = 0;
	_outerRadiusSqr = 0;
	_zeroPointer = 0;
	_startPointer = 0;
	_targetFrame = 0;

	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
	Common::String param;
	Common::String values;
	getParams(line, param, values);

	while (!stream.eos() && !line.contains('}')) {
		if (param.matchString("animation", true)) {
			_animation = _engine->loadAnimation(values);
			_animation->start();
		} else if (param.matchString("rectangle", true)) {
			int x;
			int y;
			int width;
			int height;

			sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

			_rectangle = Common::Rect(x, y, width, height);
		} else if (param.matchString("num_states", true)) {
			_statesCount = atoi(values.c_str());
		} else if (param.matchString("center", true)) {
			int x;
			int y;

			sscanf(values.c_str(), "%d %d", &x, &y);
			_center = Common::Point(x, y);
		} else if (param.matchString("dial_inner_radius", true)) {
			_innerRaduis = atoi(values.c_str());
			_innerRadiusSqr = _innerRaduis * _innerRaduis;
		} else if (param.matchString("radius", true)) {
			_outerRadius = atoi(values.c_str());
			_outerRadiusSqr = _outerRadius * _outerRadius;
		} else if (param.matchString("zero_radians_offset", true)) {
			_zeroPointer = atoi(values.c_str());
		} else if (param.matchString("pointer_offset", true)) {
			_startPointer = atoi(values.c_str());
			_curState = _startPointer;
		} else if (param.matchString("cursor", true)) {
			// Not used
		} else if (param.matchString("mirrored", true)) {
			// Not used
		} else if (param.matchString("venus_id", true)) {
			_venusId = atoi(values.c_str());
		}

		line = stream.readLine();
		_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
		getParams(line, param, values);
	}

	if (_animation)
		_animation->seekToFrame(_curState);
}
Exemplo n.º 2
0
TEST_P(HEMM, chemm) {
    TestParams params;

    getParams(&params);
    hemmCorrectnessTest<FloatComplex>(&params);
}
Exemplo n.º 3
0
static void static_dump_request_cb(struct evhttp_request *req, void *arg)
{

	const char *cmdtype;
	struct evkeyvalq *headers;
	struct evkeyval *header;
	struct evbuffer *buf;


	switch (evhttp_request_get_command(req)) {
		case EVHTTP_REQ_GET:
			cmdtype = "GET";
		break;
		case EVHTTP_REQ_POST:
			cmdtype = "POST";
		break;
		default:
			cmdtype = "unknown";
		break;
	}
	printf("Received a %s request for %s\nHeaders:\n",
	    cmdtype, evhttp_request_get_uri(req));

	headers = evhttp_request_get_input_headers(req);
	for (header = headers->tqh_first; header;
	    header = header->next.tqe_next) {
		printf("  %s: %s\n", header->key, header->value);
	}

	buf = evhttp_request_get_input_buffer(req);
	puts("Input data: <<<");
	printf("len:%d", evbuffer_get_length(buf));

	/*
	while (evbuffer_get_length(buf)) {
		int n;
		char cbuf[128];
		n = evbuffer_remove(buf, cbuf, sizeof(buf)-1);
		if (n > 0)
			(void) fwrite(cbuf, 1, n, stdout);
	}
	puts(">>>");
	*/

	//get params
	struct evkeyvalq *query_params_ptr = calloc(sizeof(struct evkeyvalq), 1);
	getParams(req, query_params_ptr);
	char *test = NULL;
	test = getParam(query_params_ptr, "test");
	if (test != NULL) {
		fprintf(stderr, "param test: %s", test);
	}
	evhttp_clear_headers(query_params_ptr);
	free(test);


	//post params
	struct evkeyvalq *post_params_ptr = calloc(sizeof(struct evkeyvalq), 1);
	postParams(req, post_params_ptr);
	char *name = NULL;
	name = postParam(post_params_ptr, "name");
	if (name != NULL) {
		fprintf(stderr, "param name: %s", name);
	}

	evhttp_clear_headers(post_params_ptr);
	free(name);

	evhttp_send_reply(req, 200, "OK", NULL);

	//evhttp_request_free(req);
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) //this main function should return error value, 0 = OK
{
    /* check for program parameters */
    if((getParams(argc, argv) < 0)) {help(); return -1;}

    QCoreApplication a(argc, argv);

    // Task parented to the application so that it will be deleted by the application.
    Task *task = new Task(&a);

    // Initialize the network
    task->_init(static_cast<FG::pdfType>(pdfType), nStates, vRange, extRatio, gVar);

    // train or load jpd?
    if(jpdName.isNull() || jpdName.isEmpty()) //then train jpd
    {
        if(datasetName.isNull() || datasetName.isEmpty())
        {
            printf("Cannot train jpd! Missing dataset file!!!\n"); return -1;
        } else
        {
            if(!task->_trainJPD(datasetName))
            {
                printf("Error during training jpd!\n"); return -1;
            }
            else
            {
                resultFileName = datasetName;
                resultFileName.append(".res");
            }
        }
    }
    else
    {
        if(!task->_loadJPD(jpdName))
        {
            printf("Error during loading the jpd file!\n"); return -1;
        }
        else
        {
            resultFileName = jpdName;
            resultFileName.replace(".jpd",".res");
        }
    }
    task->_setResultFile(resultFileName);   //this filename will be used during run()
    task->_setInferMode(datasetInference);

    /* print parameter information */
    qDebug() << QString("Dataset name: %1").arg(datasetName);
    qDebug() << QString("JPD name: %1").arg(jpdName);
    qDebug() << QString("Result filename: %1").arg(resultFileName);

    // This will cause the application to exit when the task signals finished.
    QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));

    // This will run the task from the application event loop.
    QTimer::singleShot(0, task, SLOT(run()));

    return a.exec();

}
Exemplo n.º 5
0
TEST_P(HPMV, zhpmv) {
    TestParams params;

    getParams(&params);
    hpmvCorrectnessTest<DoubleComplex>(&params);
}
Exemplo n.º 6
0
TEST_P(GBMV, sgbmv) {
    TestParams params;

    getParams(&params);
    gbmvCorrectnessTest<cl_float>(&params);
}
Exemplo n.º 7
0
TEST_P(GBMV, cgbmv) {
    TestParams params;

    getParams(&params);
    gbmvCorrectnessTest<FloatComplex>(&params);
}
Exemplo n.º 8
0
    PriorBoxLayerImpl(const LayerParams &params)
    {
        setParamsFrom(params);
        _minSize = getParameter<float>(params, "min_size", 0, false, 0);
        _flip = getParameter<bool>(params, "flip", 0, false, true);
        _clip = getParameter<bool>(params, "clip", 0, false, true);
        _bboxesNormalized = getParameter<bool>(params, "normalized_bbox", 0, false, true);

        _aspectRatios.clear();

        getAspectRatios(params);
        getVariance(params);

        _maxSize = -1;
        if (params.has("max_size"))
        {
            _maxSize = params.get("max_size").get<float>(0);
            CV_Assert(_maxSize > _minSize);
        }

        std::vector<float> widths, heights;
        getParams("width", params, &widths);
        getParams("height", params, &heights);
        _explicitSizes = !widths.empty();
        CV_Assert(widths.size() == heights.size());

        if (_explicitSizes)
        {
            CV_Assert(_aspectRatios.empty());
            CV_Assert(!params.has("min_size"));
            CV_Assert(!params.has("max_size"));
            _boxWidths = widths;
            _boxHeights = heights;
        }
        else
        {
            CV_Assert(_minSize > 0);
            _boxWidths.resize(1 + (_maxSize > 0 ? 1 : 0) + _aspectRatios.size());
            _boxHeights.resize(_boxWidths.size());
            _boxWidths[0] = _boxHeights[0] = _minSize;

            int i = 1;
            if (_maxSize > 0)
            {
                // second prior: aspect_ratio = 1, size = sqrt(min_size * max_size)
                _boxWidths[i] = _boxHeights[i] = sqrt(_minSize * _maxSize);
                i += 1;
            }

            // rest of priors
            for (size_t r = 0; r < _aspectRatios.size(); ++r)
            {
                float arSqrt = sqrt(_aspectRatios[r]);
                _boxWidths[i + r] = _minSize * arSqrt;
                _boxHeights[i + r] = _minSize / arSqrt;
            }
        }
        CV_Assert(_boxWidths.size() == _boxHeights.size());
        _numPriors = _boxWidths.size();

        if (params.has("step_h") || params.has("step_w")) {
          CV_Assert(!params.has("step"));
          _stepY = getParameter<float>(params, "step_h");
          CV_Assert(_stepY > 0.);
          _stepX = getParameter<float>(params, "step_w");
          CV_Assert(_stepX > 0.);
        } else if (params.has("step")) {
          const float step = getParameter<float>(params, "step");
          CV_Assert(step > 0);
          _stepY = step;
          _stepX = step;
        } else {
          _stepY = 0;
          _stepX = 0;
        }
        if (params.has("offset_h") || params.has("offset_w"))
        {
            CV_Assert(!params.has("offset"), params.has("offset_h"), params.has("offset_w"));
            getParams("offset_h", params, &_offsetsY);
            getParams("offset_w", params, &_offsetsX);
            CV_Assert(_offsetsX.size() == _offsetsY.size());
            _numPriors *= std::max((size_t)1, 2 * (_offsetsX.size() - 1));
        }
        else
        {
            float offset = getParameter<float>(params, "offset", 0, false, 0.5);
            _offsetsX.assign(1, offset);
            _offsetsY.assign(1, offset);
        }
    }
Exemplo n.º 9
0
TEST_P(TRSM, strsm) {
    TestParams params;

    getParams(&params);
    trsmCorrectnessTest<cl_float>(&params);
}
Exemplo n.º 10
0
TEST_P(GEMM, sgemm) {
    TestParams params;

    getParams(&params);
    gemmCorrectnessTest<cl_float>(&params);
}
Exemplo n.º 11
0
TEST_P(GEMM, dgemm) {
    TestParams params;

    getParams(&params);
    gemmCorrectnessTest<cl_double>(&params);
}
Exemplo n.º 12
0
/* int main()
 * Main.
 */
int main(int argc, char* argv[]) {
  getParams(argc, argv);
  return 0;
}
Exemplo n.º 13
0
void TExternalProgramFx::doCompute(TTile &tile, double frame,
                                   const TRenderSettings &ri) {
  TRaster32P ras = tile.getRaster();
  if (!ras) return;
  std::string args           = m_args;
  std::string executablePath = ::to_string(m_executablePath);
  std::map<std::string, TFilePath> tmpFiles;  // portname --> file
  TFilePath outputTmpFile;

  std::map<std::string, Port>::const_iterator portIt;
  for (portIt = m_ports.begin(); portIt != m_ports.end(); ++portIt) {
    TFilePath fp            = TSystem::getUniqueFile("externfx");
    fp                      = fp.withType(portIt->second.m_ext);
    tmpFiles[portIt->first] = fp;
    if (portIt->second.m_port == 0)  // solo una porta e' di output
      outputTmpFile = fp;
    else {
      TRasterFxPort *tmp;
      tmp = portIt->second.m_port;
      if (tmp->isConnected()) {
        (*tmp)->compute(tile, frame, ri);
        TImageWriter::save(fp, ras);
      }
    }
  }

  // args e' della forma "$src $ctrl -o $out -v $value"
  // sostituisco le variabili
  int i = 0;
  for (;;) {
    i = args.find('$', i);
    if (i == (int)std::string::npos) break;
    int j   = i + 1;
    int len = args.length();
    while (j < len && isalnum(args[j])) j++;
    // un '$' non seguito da caratteri alfanumerici va ignorato
    if (j == i + 1) {
      // la sequenza '$$' diventa '$'
      if (j < len && args[j] == '$') args.replace(i, 2, "$");
      i++;
      continue;
    }
    // ho trovato una variabile
    int m            = j - i - 1;
    std::string name = args.substr(i + 1, m);
    // calcolo il valore.
    std::string value;

    std::map<std::string, TFilePath>::const_iterator it;
    it = tmpFiles.find(name);
    if (it != tmpFiles.end()) {
      // e' una porta. il valore e' il nome del
      // file temporaneo
      value = "\"" + ::to_string(it->second.getWideString()) + "\"";
    } else {
      // e' un parametro
      // se il nome non viene riconosciuto sostituisco la stringa nulla
      TDoubleParamP param = TParamP(getParams()->getParam(name));
      if (param) value    = std::to_string(param->getValue(frame));
    }

    args.replace(i, m + 1, value);
  }
  args = " " + args;  // aggiungo uno spazio per sicurezza
  // ofstream os("C:\\temp\\butta.txt");
  // os << args << endl;

  // bisognerebbe calcolare le immagini dalla/e porta/e di input
  // scrivere il/i valore/i nei files temporanei/o
  // chiamare "m_executablePath args"
  // e leggere l'immagine scritta in outputTmpFile
  // poi cancellare tutto
  std::string expandedargs;
  char buffer[1024];
#ifdef _WIN32
  ExpandEnvironmentStrings(args.c_str(), buffer, 1024);

  STARTUPINFO si;
  PROCESS_INFORMATION pinfo;

  GetStartupInfo(&si);

  BOOL ret = CreateProcess(
      (char *)executablePath.c_str(),           // name of executable module
      buffer,                                   // command line string
      NULL,                                     // SD
      NULL,                                     // SD
      TRUE,                                     // handle inheritance option
      CREATE_NO_WINDOW, /*CREATE_NEW_CONSOLE*/  // creation flags
      NULL,                                     // new environment block
      NULL,                                     // current directory name
      &si,                                      // startup information
      &pinfo                                    // process information
      );

  if (!ret) DWORD err = GetLastError();

  // aspetta che il processo termini
  WaitForSingleObject(pinfo.hProcess, INFINITE);

  DWORD exitCode;
  ret = GetExitCodeProcess(pinfo.hProcess,  // handle to the process
                           &exitCode);      // termination status

#else
  std::string cmdline = executablePath + buffer;
  //    int exitCode =
  system(cmdline.c_str());
#endif
  /*
string name = m_executablePath.getName();
TPixel32 color;
if(name == "saturate") color = TPixel32::Magenta;
else if(name == "over") color = TPixel32::Green;
else color = TPixel32::Red;
for(int iy=0;iy<ras->getLy();iy++)
{
TPixel32 *pix = ras->pixels(iy);
TPixel32 *endPix = pix + ras->getLx();
double x = tile.m_pos.x;
double y = tile.m_pos.y + iy;
while(pix<endPix)
 {
  if(x*x+y*y<900) *pix = color;
  else *pix = TPixel32(0,0,0,0);
  ++pix;
  x+=1.0;
 }
}
*/

  try {
    TRasterP ras = tile.getRaster();
    TImageReader::load(outputTmpFile, ras);
  } catch (...) {
  }

  // butto i file temporanei creati
  std::map<std::string, TFilePath>::const_iterator fileIt;
  for (fileIt = tmpFiles.begin(); fileIt != tmpFiles.end(); ++fileIt) {
    if (TFileStatus(fileIt->second).doesExist() == true) try {
        TSystem::deleteFile(fileIt->second);
      } catch (...) {
      }
  }
  if (TFileStatus(outputTmpFile).doesExist() == true) try {
      TSystem::deleteFile(outputTmpFile);
    } catch (...) {
    }
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    char *input, *output;
    int convertNull;
    char nullValue[256];
    int useTypeDefault, type, useCompressionDefault, doCompression;
    int usePrecisionDefault, precision, useDimensionDefault, tileX, tileY,
        tileZ;
    RASTER3D_Region region;
    FILE *fp;
    struct GModule *module;
    struct History history;

    map = NULL;

    G_gisinit(argv[0]);
    module = G_define_module();
    G_add_keyword(_("raster3d"));
    G_add_keyword(_("import"));
    G_add_keyword(_("voxel"));
    G_add_keyword(_("conversion"));
    G_add_keyword("ASCII");
    module->description =
        _("Converts a 3D ASCII raster text file into a (binary) 3D raster map.");

    setParams();
    Rast3d_set_standard3d_input_params();

    if (G_parser(argc, argv))
        exit(EXIT_FAILURE);

    getParams(&input, &output, &convertNull, nullValue);
    if (!Rast3d_get_standard3d_params(&useTypeDefault, &type,
                                 &useCompressionDefault, &doCompression,
                                 &usePrecisionDefault, &precision,
                                 &useDimensionDefault, &tileX, &tileY,
                                 &tileZ))
        fatalError("Error getting standard parameters");

    Rast3d_init_defaults();

    fp = openAscii(input, &region);

    /*Open the new RASTER3D map */
    map = Rast3d_open_new_param(output, RASTER3D_TILE_SAME_AS_FILE, RASTER3D_USE_CACHE_XY,
                           &region,
                           type, doCompression, precision, tileX, tileY,
                           tileZ);

    if (map == NULL)
        fatalError(_("Unable to open 3D raster map"));

    /*Create the new RASTER3D Map */
    asciiToG3d(fp, &region, convertNull, nullValue);

    if (!Rast3d_close(map))
        fatalError(_("Unable to close 3D raster map"));

    /* write input name to map history */
    Rast3d_read_history(output, G_mapset(), &history);
    Rast_command_history(&history);
    Rast_set_history(&history, HIST_DATSRC_1, input);
    Rast3d_write_history(output, &history);

    map = NULL;
    if (fclose(fp))
        fatalError(_("Unable to close ASCII file"));

    return EXIT_SUCCESS;
}
Exemplo n.º 15
0
ReferenceGeneratorPanel::ReferenceGeneratorPanel(QWidget* parent) : rviz::Panel(parent), nh_(""), nh_local_("reference_generator") {
  params_cli_ = nh_local_.serviceClient<std_srvs::Empty>("params");
  getParams();

  activate_checkbox_ = new QCheckBox("On/Off");
  activate_checkbox_->setChecked(p_active_);

  stop_button_ = new QPushButton();
  pause_button_ = new QPushButton();
  play_button_ = new QPushButton();

  set_button_ = new QPushButton("Set");
  set_button_->setEnabled(p_active_);

  stop_button_->setMinimumSize(50, 50);
  stop_button_->setMaximumSize(50, 50);
  stop_button_->setCheckable(true);
  stop_button_->setEnabled(p_active_ && !p_stopped_);
  stop_button_->setChecked(p_stopped_ && !p_paused_);
  stop_button_->setIcon(QIcon("/home/ksis/catkin_ws/src/mrop_gui/resources/stop.png"));
  stop_button_->setIconSize(QSize(25, 25));

  pause_button_->setMinimumSize(50, 50);
  pause_button_->setMaximumSize(50, 50);
  pause_button_->setCheckable(true);
  pause_button_->setEnabled(p_active_ && !p_paused_);
  pause_button_->setChecked(p_paused_ && !p_stopped_);
  pause_button_->setIcon(QIcon("/home/ksis/catkin_ws/src/mrop_gui/resources/pause.png"));
  pause_button_->setIconSize(QSize(25, 25));

  play_button_->setMinimumSize(50, 50);
  play_button_->setMaximumSize(50, 50);
  play_button_->setCheckable(true);
  play_button_->setEnabled(p_active_ && (p_stopped_ || p_paused_));
  play_button_->setChecked(!p_paused_ && !p_stopped_);
  play_button_->setIcon(QIcon("/home/ksis/catkin_ws/src/mrop_gui/resources/play.png"));
  play_button_->setIconSize(QSize(25, 25));

  QSpacerItem* margin = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed);

  QHBoxLayout* buttons_layout = new QHBoxLayout;
  buttons_layout->addSpacerItem(margin);
  buttons_layout->addWidget(stop_button_);
  buttons_layout->addWidget(pause_button_);
  buttons_layout->addWidget(play_button_);
  buttons_layout->addSpacerItem(margin);

  trajectories_list_ = new QComboBox();
  trajectories_list_->addItem("Point");
  trajectories_list_->addItem("Linear");
  trajectories_list_->addItem("Harmonic");
  trajectories_list_->addItem("Lemniscate");
  trajectories_list_->setEnabled(p_active_);
  trajectories_list_->setCurrentIndex(p_trajectory_type_);

  x_input_ = new QLineEdit(QString::number(p_x_0_));
  y_input_ = new QLineEdit(QString::number(p_y_0_));
  theta_input_ = new QLineEdit(QString::number(p_theta_0_));
  v_input_ = new QLineEdit(QString::number(p_v_));
  T_input_ = new QLineEdit(QString::number(p_T_));
  r_x_input_ = new QLineEdit(QString::number(p_r_x_));
  r_y_input_ = new QLineEdit(QString::number(p_r_y_));
  n_x_input_ = new QLineEdit(QString::number(p_n_x_));
  n_y_input_ = new QLineEdit(QString::number(p_n_y_));

  chooseTrajectoryParams(p_trajectory_type_);

  QString theta = QChar(0x03B8);

  QGridLayout* inputs_layout = new QGridLayout;
  inputs_layout->addItem(margin, 0, 0);
  inputs_layout->addWidget(new QLabel("x:"), 0, 1);
  inputs_layout->addWidget(x_input_, 0, 2);
  inputs_layout->addWidget(new QLabel("m, "), 0, 3);
  inputs_layout->addWidget(new QLabel("y:"), 0, 4);
  inputs_layout->addWidget(y_input_, 0, 5);
  inputs_layout->addWidget(new QLabel("m, "), 0, 6);
  inputs_layout->addWidget(new QLabel(theta + ":"), 0, 7);
  inputs_layout->addWidget(theta_input_, 0, 8);
  inputs_layout->addWidget(new QLabel("rad"), 0, 9);
  inputs_layout->addItem(margin, 0, 10);
  //
  inputs_layout->addItem(margin, 1, 0);
  inputs_layout->addWidget(new QLabel("v:"), 1, 1);
  inputs_layout->addWidget(v_input_, 1, 2);
  inputs_layout->addWidget(new QLabel("m/s, "), 1, 3);
  inputs_layout->addWidget(new QLabel("n<sub>x</sub>:"), 1, 4);
  inputs_layout->addWidget(n_x_input_, 1, 5);
  inputs_layout->addWidget(new QLabel("-, "), 1, 6);
  inputs_layout->addWidget(new QLabel("n<sub>y</sub>:"), 1, 7);
  inputs_layout->addWidget(n_y_input_, 1, 8);
  inputs_layout->addWidget(new QLabel("-"), 1, 9);
  inputs_layout->addItem(margin, 1, 10);
  //
  inputs_layout->addItem(margin, 2, 0);
  inputs_layout->addWidget(new QLabel("T:"), 2, 1);
  inputs_layout->addWidget(T_input_, 2, 2);
  inputs_layout->addWidget(new QLabel("s, "), 2, 3);
  inputs_layout->addWidget(new QLabel("r<sub>x</sub>:"), 2, 4);
  inputs_layout->addWidget(r_x_input_, 2, 5);
  inputs_layout->addWidget(new QLabel("m, "), 2, 6);
  inputs_layout->addWidget(new QLabel("r<sub>y</sub>:"), 2, 7);
  inputs_layout->addWidget(r_y_input_, 2, 8);
  inputs_layout->addWidget(new QLabel("m"), 2, 9);
  inputs_layout->addItem(margin, 2, 10);

  QVBoxLayout* layout = new QVBoxLayout;
  layout->addWidget(activate_checkbox_);
  layout->addLayout(buttons_layout);
  layout->addWidget(trajectories_list_);
  layout->addLayout(inputs_layout);
  layout->addWidget(set_button_);
  layout->setAlignment(layout, Qt::AlignCenter);
  setLayout(layout);

  connect(activate_checkbox_, SIGNAL(clicked(bool)), this, SLOT(trigger(bool)));
  connect(stop_button_, SIGNAL(clicked()), this, SLOT(stop()));
  connect(pause_button_, SIGNAL(clicked()), this, SLOT(pause()));
  connect(play_button_, SIGNAL(clicked()), this, SLOT(start()));
  connect(set_button_, SIGNAL(clicked()), this, SLOT(setParamsButton()));
  connect(trajectories_list_, SIGNAL(activated(int)), this, SLOT(chooseTrajectoryParams(int)));
}
Exemplo n.º 16
0
TEST_P(TRSM, dtrsm) {
    TestParams params;

    getParams(&params);
    trsmCorrectnessTest<cl_double>(&params);
}
Exemplo n.º 17
0
int main()
{
#ifdef DEBUG_MEM_LEAK_ALLOC_CRASH
  _CrtSetBreakAlloc(DEBUG_MEM_LEAK_ALLOC_ADDR);
#endif

  {

    Image* img = NULL;
    Vec3* eye = NULL;
    int nObj = 0, nSrc = 0;
    Object **obj = NULL, **src = NULL;

    std::cout << "Calling cfg parser." << std::endl;
    getParams(CONFIG_FILE_PATH);

    sceneParser(SCENE_PATH, &obj, &nObj, &src, &nSrc, &img, &eye);

    /* ~~~ Start rendering. ~~~ */
    std::cout << "Creating test world\n";
    TestWorld world = TestWorld(obj, nObj, src, nSrc, *eye, img, 1.0f);
#ifdef EN_PARALLEL_PROC
    par_proc_testWorld = &world;
#endif
    world.runTest();

    /* Delete allocated objects and sources. */
    /* First delete objects. */
    for (int j = 0; j < nObj; j++)
    {
      bool skipThisObj = false;
      /* Don't delete if we're going to delete it in the sources list later. */
      for (int k = 0; k < nSrc; k++)
      {
        if (obj[j] == src[k])
        {
          skipThisObj = true;
          break;
        }
      }
      if (skipThisObj)
      {
        continue;
      }
      /* No repeat in source list, go ahead and delete. */
      std::cout << "Del obj " << j << "\n";
      delete obj[j];
    }
    /* delete the array itself. */
    delete[] obj;

    for (int j = 0; j < nSrc; j++)
    {
      std::cout << "Del src " << j << "\n";
      delete src[j];
    }
    /* delete the array itself. */
    delete[] src;

    img->autoScale();
    img->exportBitmap(OUTPUT_IMG);

    delete img;
    delete eye;

    std::cout << "End\n";
  }

#ifdef DEBUG_MEM_LEAK_REPORT
  _CrtDumpMemoryLeaks();
#endif

  return 0;
}
Exemplo n.º 18
0
TEST_P(TRSM, ctrsm) {
    TestParams params;

    getParams(&params);
    trsmCorrectnessTest<FloatComplex>(&params);
}
Exemplo n.º 19
0
TEST_P(GBMV, dgbmv) {
    TestParams params;

    getParams(&params);
    gbmvCorrectnessTest<cl_double>(&params);
}
Exemplo n.º 20
0
TEST_P(TRSM, ztrsm) {
    TestParams params;

    getParams(&params);
    trsmCorrectnessTest<DoubleComplex>(&params);
}
Exemplo n.º 21
0
TEST_P(GBMV, zgbmv) {
    TestParams params;

    getParams(&params);
    gbmvCorrectnessTest<DoubleComplex>(&params);
}
Exemplo n.º 22
0
Arquivo: init.c Projeto: ajaymills/RCL
void parseUserInput(int argc, char** argv) {
	int c;
	char configfile[30];
	int outfileSpecified=0;
	int configfileSpecified=0;
	int scaleSpecified=0;	
	if (argc == 1) {
		fprintf(stderr, "GTgraph-ssca2 [-options]\n");
		fprintf(stderr, "\t-s ###  SCALE value (integer) to use (default -- 20)\n"); 
		fprintf(stderr, "\t-c ###  config file to use\n");
		fprintf(stderr, "\t-o ###  output file to write the graph to (default -- sample.gr)\n");
		fprintf(stderr, "\t-h      display this message\n");
		fprintf(stderr, "No config file specified\n");
		fprintf(stderr, "Assigning default values from init.c\n");
		getParams();
		updateLog();

	} else if (argc <= 5) {

		while((c = getopt(argc, argv, "s:c:h:o:")) != -1) {

			switch (c) {
				
			case 's':
				if ((!configfileSpecified) && (!outfileSpecified)) {
					getParams();
				} else if (configfileSpecified) {
					fprintf(stderr, "Warning: Ignoring the SCALE value given as an input argument. The parameters specified in the config file have been applied\n");
					break;
				}
				SCALE = atol(optarg);
                                fprintf(stderr, "Applying a SCALE value of %ld\n", SCALE);
                                TotVertices = 1 << SCALE;
                                MaxCliqueSize = (LONG_T) floor(pow(2, (double) (SCALE/3.0)));
                                MaxWeight = 1 << SCALE;
                                updateLog();
				scaleSpecified = 1;
				break;
					
				case 'o':
				outfileSpecified = 1;
				if ((!configfileSpecified) && (!scaleSpecified)) {
					fprintf(stderr, "No config file specified, assigning default values ...\n");
					getParams();
				}
				WRITE_TO_FILE = 1;
				strcpy(OUTFILE, optarg);
				fprintf(stderr, "Graph will be written to %s\n", OUTFILE);
				updateLog();
				
				break;
				
				case 'c':
				if (scaleSpecified) {
					fprintf(stderr, "Warning: The parameters specified in the config file will be applied and the previous SCALE value will be lost\n");
				}
				configfileSpecified = 1;
				if (!outfileSpecified) {
					if (!scaleSpecified)
						getParams();
					strcpy(configfile, optarg);
					fprintf(stderr, "Reading config file %s\n", configfile);
					getParamsFromFile(configfile);
				} else {
					strcpy(configfile, optarg);
					fprintf(stderr, "Updating parameters from config file %s\n", configfile);
					getParamsFromFile(configfile);
				}
				updateLog();
				
				break;
			
				case 'h':
					usage();

				default:
					usage();
			}
		}

		
	} else {
		fprintf(stderr, "Invalid input arguments\n");
		usage();
	}
	
}
Exemplo n.º 23
0
TEST_P(HPMV, chpmv) {
    TestParams params;

    getParams(&params);
    hpmvCorrectnessTest<FloatComplex>(&params);
}
Exemplo n.º 24
0
TEST_P(SPR, sspr) {
    TestParams params;

    getParams(&params);
    sprCorrectnessTest<cl_float>(&params);
}
Exemplo n.º 25
0
void CalibrationDialog::processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName)
{
	processingData_ = true;
	if(cameraName_.isEmpty())
	{
		cameraName_ = "0000";
		if(!cameraName.isEmpty())
		{
			cameraName_ = cameraName;
		}
	}
	if(ui_->label_serial->text().isEmpty())
	{
		ui_->label_serial->setText(cameraName_);

	}
	std::vector<cv::Mat> inputRawImages(2);
	if(ui_->checkBox_switchImages->isChecked())
	{
		inputRawImages[0] = imageRight;
		inputRawImages[1] = imageLeft;
	}
	else
	{
		inputRawImages[0] = imageLeft;
		inputRawImages[1] = imageRight;
	}

	std::vector<cv::Mat> images(2);
	images[0] = inputRawImages[0];
	images[1] = inputRawImages[1];
	imageSize_[0] = images[0].size();
	imageSize_[1] = images[1].size();

	bool boardFound[2] = {false};
	bool boardAccepted[2] = {false};
	bool readyToCalibrate[2] = {false};

	std::vector<std::vector<cv::Point2f> > pointBuf(2);

	bool depthDetected = false;
	for(int id=0; id<(stereo_?2:1); ++id)
	{
		cv::Mat viewGray;
		if(!images[id].empty())
		{
			if(images[id].type() == CV_16UC1)
			{
				depthDetected = true;
				//assume IR image: convert to gray scaled
				const float factor = 255.0f / float((maxIrs_[id] - minIrs_[id]));
				viewGray = cv::Mat(images[id].rows, images[id].cols, CV_8UC1);
				for(int i=0; i<images[id].rows; ++i)
				{
					for(int j=0; j<images[id].cols; ++j)
					{
						viewGray.at<unsigned char>(i, j) = (unsigned char)std::min(float(std::max(images[id].at<unsigned short>(i,j) - minIrs_[id], 0)) * factor, 255.0f);
					}
				}
				cvtColor(viewGray, images[id], cv::COLOR_GRAY2BGR); // convert to show detected points in color
			}
			else if(images[id].channels() == 3)
			{
				cvtColor(images[id], viewGray, cv::COLOR_BGR2GRAY);
			}
			else
			{
				viewGray = images[id];
				cvtColor(viewGray, images[id], cv::COLOR_GRAY2BGR); // convert to show detected points in color
			}
		}
		else
		{
			UERROR("Image %d is empty!! Should not!", id);
		}

		minIrs_[id] = 0;
		maxIrs_[id] = 0x7FFF;

		//Dot it only if not yet calibrated
		if(!ui_->pushButton_save->isEnabled())
		{
			cv::Size boardSize(ui_->spinBox_boardWidth->value(), ui_->spinBox_boardHeight->value());
			if(!viewGray.empty())
			{
				int flags = CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE;

				if(!viewGray.empty())
				{
					int maxScale = viewGray.cols < 640?2:1;
					for( int scale = 1; scale <= maxScale; scale++ )
					{
						cv::Mat timg;
						if( scale == 1 )
							timg = viewGray;
						else
							cv::resize(viewGray, timg, cv::Size(), scale, scale, CV_INTER_CUBIC);
						boardFound[id] = cv::findChessboardCorners(timg, boardSize, pointBuf[id], flags);
						if(boardFound[id])
						{
							if( scale > 1 )
							{
								cv::Mat cornersMat(pointBuf[id]);
								cornersMat *= 1./scale;
							}
							break;
						}
					}
				}
			}

			if(boardFound[id]) // If done with success,
			{
				// improve the found corners' coordinate accuracy for chessboard
				float minSquareDistance = -1.0f;
				for(unsigned int i=0; i<pointBuf[id].size()-1; ++i)
				{
					float d = cv::norm(pointBuf[id][i] - pointBuf[id][i+1]);
					if(minSquareDistance == -1.0f || minSquareDistance > d)
					{
						minSquareDistance = d;
					}
				}
				float radius = minSquareDistance/2.0f +0.5f;
				cv::cornerSubPix( viewGray, pointBuf[id], cv::Size(radius, radius), cv::Size(-1,-1),
						cv::TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1 ));

				// Draw the corners.
				cv::drawChessboardCorners(images[id], boardSize, cv::Mat(pointBuf[id]), boardFound[id]);

				std::vector<float> params(4,0);
				getParams(pointBuf[id], boardSize, imageSize_[id], params[0], params[1], params[2], params[3]);

				bool addSample = true;
				for(unsigned int i=0; i<imageParams_[id].size(); ++i)
				{
					if(fabs(params[0] - imageParams_[id][i].at(0)) < 0.1 && // x
						fabs(params[1] - imageParams_[id][i].at(1)) < 0.1 && // y
						fabs(params[2] - imageParams_[id][i].at(2)) < 0.05 && // size
						fabs(params[3] - imageParams_[id][i].at(3)) < 0.1) // skew
					{
						addSample = false;
					}
				}
				if(addSample)
				{
					boardAccepted[id] = true;

					imagePoints_[id].push_back(pointBuf[id]);
					imageParams_[id].push_back(params);

					UINFO("[%d] Added board, total=%d. (x=%f, y=%f, size=%f, skew=%f)", id, (int)imagePoints_[id].size(), params[0], params[1], params[2], params[3]);
				}

				// update statistics
				std::vector<float> xRange(2, imageParams_[id][0].at(0));
				std::vector<float> yRange(2, imageParams_[id][0].at(1));
				std::vector<float> sizeRange(2, imageParams_[id][0].at(2));
				std::vector<float> skewRange(2, imageParams_[id][0].at(3));
				for(unsigned int i=1; i<imageParams_[id].size(); ++i)
				{
					xRange[0] = imageParams_[id][i].at(0) < xRange[0] ? imageParams_[id][i].at(0) : xRange[0];
					xRange[1] = imageParams_[id][i].at(0) > xRange[1] ? imageParams_[id][i].at(0) : xRange[1];
					yRange[0] = imageParams_[id][i].at(1) < yRange[0] ? imageParams_[id][i].at(1) : yRange[0];
					yRange[1] = imageParams_[id][i].at(1) > yRange[1] ? imageParams_[id][i].at(1) : yRange[1];
					sizeRange[0] = imageParams_[id][i].at(2) < sizeRange[0] ? imageParams_[id][i].at(2) : sizeRange[0];
					sizeRange[1] = imageParams_[id][i].at(2) > sizeRange[1] ? imageParams_[id][i].at(2) : sizeRange[1];
					skewRange[0] = imageParams_[id][i].at(3) < skewRange[0] ? imageParams_[id][i].at(3) : skewRange[0];
					skewRange[1] = imageParams_[id][i].at(3) > skewRange[1] ? imageParams_[id][i].at(3) : skewRange[1];
				}
				//UINFO("Stats [%d]:", id);
				//UINFO("  Count = %d", (int)imagePoints_[id].size());
				//UINFO("  x =    [%f -> %f]", xRange[0], xRange[1]);
				//UINFO("  y =    [%f -> %f]", yRange[0], yRange[1]);
				//UINFO("  size = [%f -> %f]", sizeRange[0], sizeRange[1]);
				//UINFO("  skew = [%f -> %f]", skewRange[0], skewRange[1]);

				float xGood = xRange[1] - xRange[0];
				float yGood = yRange[1] - yRange[0];
				float sizeGood = sizeRange[1] - sizeRange[0];
				float skewGood = skewRange[1] - skewRange[0];

				if(id == 0)
				{
					ui_->progressBar_x->setValue(xGood*100);
					ui_->progressBar_y->setValue(yGood*100);
					ui_->progressBar_size->setValue(sizeGood*100);
					ui_->progressBar_skew->setValue(skewGood*100);
					if((int)imagePoints_[id].size() > ui_->progressBar_count->maximum())
					{
						ui_->progressBar_count->setMaximum((int)imagePoints_[id].size());
					}
					ui_->progressBar_count->setValue((int)imagePoints_[id].size());
				}
				else
				{
					ui_->progressBar_x_2->setValue(xGood*100);
					ui_->progressBar_y_2->setValue(yGood*100);
					ui_->progressBar_size_2->setValue(sizeGood*100);
					ui_->progressBar_skew_2->setValue(skewGood*100);

					if((int)imagePoints_[id].size() > ui_->progressBar_count_2->maximum())
					{
						ui_->progressBar_count_2->setMaximum((int)imagePoints_[id].size());
					}
					ui_->progressBar_count_2->setValue((int)imagePoints_[id].size());
				}

				if(imagePoints_[id].size() >= COUNT_MIN && xGood > 0.5 && yGood > 0.5 && sizeGood > 0.4 && skewGood > 0.5)
				{
					readyToCalibrate[id] = true;
				}

				//update IR values
				if(inputRawImages[id].type() == CV_16UC1)
				{
					//update min max IR if the chessboard was found
					minIrs_[id] = 0xFFFF;
					maxIrs_[id] = 0;
					for(size_t i = 0; i < pointBuf[id].size(); ++i)
					{
						const cv::Point2f &p = pointBuf[id][i];
						cv::Rect roi(std::max(0, (int)p.x - 3), std::max(0, (int)p.y - 3), 6, 6);

						roi.width = std::min(roi.width, inputRawImages[id].cols - roi.x);
						roi.height = std::min(roi.height, inputRawImages[id].rows - roi.y);

						//find minMax in the roi
						double min, max;
						cv::minMaxLoc(inputRawImages[id](roi), &min, &max);
						if(min < minIrs_[id])
						{
							minIrs_[id] = min;
						}
						if(max > maxIrs_[id])
						{
							maxIrs_[id] = max;
						}
					}
				}
			}
		}
	}
	ui_->label_baseline->setVisible(!depthDetected);
	ui_->label_baseline_name->setVisible(!depthDetected);

	if(stereo_ && ((boardAccepted[0] && boardFound[1]) || (boardAccepted[1] && boardFound[0])))
	{
		stereoImagePoints_[0].push_back(pointBuf[0]);
		stereoImagePoints_[1].push_back(pointBuf[1]);
		UINFO("Add stereo image points (size=%d)", (int)stereoImagePoints_[0].size());
	}

	if(!stereo_ && readyToCalibrate[0])
	{
		ui_->pushButton_calibrate->setEnabled(true);
	}
	else if(stereo_ && readyToCalibrate[0] && readyToCalibrate[1] && stereoImagePoints_[0].size())
	{
		ui_->pushButton_calibrate->setEnabled(true);
	}

	if(ui_->radioButton_rectified->isChecked())
	{
		if(models_[0].isValid())
		{
			images[0] = models_[0].rectifyImage(images[0]);
		}
		if(models_[1].isValid())
		{
			images[1] = models_[1].rectifyImage(images[1]);
		}
	}
	else if(ui_->radioButton_stereoRectified->isChecked() &&
			(stereoModel_.left().isValid() &&
			stereoModel_.right().isValid()&&
			(!ui_->label_baseline->isVisible() || stereoModel_.baseline() > 0.0)))
	{
		images[0] = stereoModel_.left().rectifyImage(images[0]);
		images[1] = stereoModel_.right().rectifyImage(images[1]);
	}

	if(ui_->checkBox_showHorizontalLines->isChecked())
	{
		for(int id=0; id<(stereo_?2:1); ++id)
		{
			int step = imageSize_[id].height/16;
			for(int i=step; i<imageSize_[id].height; i+=step)
			{
				cv::line(images[id], cv::Point(0, i), cv::Point(imageSize_[id].width, i), CV_RGB(0,255,0));
			}
		}
	}

	ui_->label_left->setText(tr("%1x%2").arg(images[0].cols).arg(images[0].rows));

	//show frame
	ui_->image_view->setImage(uCvMat2QImage(images[0]).mirrored(ui_->checkBox_mirror->isChecked(), false));
	if(stereo_)
	{
		ui_->label_right->setText(tr("%1x%2").arg(images[1].cols).arg(images[1].rows));
		ui_->image_view_2->setImage(uCvMat2QImage(images[1]).mirrored(ui_->checkBox_mirror->isChecked(), false));
	}
	processingData_ = false;
}
Exemplo n.º 26
0
TEST_P(SPR, dspr) {
    TestParams params;

    getParams(&params);
    sprCorrectnessTest<cl_double>(&params);
}
Exemplo n.º 27
0
TEST_P(HEMM, zhemm) {
    TestParams params;

    getParams(&params);
    hemmCorrectnessTest<DoubleComplex>(&params);
}
Exemplo n.º 28
0
int main(int argc, char *argv[])
{
  int width, height, maxiter, flag;
  double x[2], y[2], c[2];
  char *image, *stats;

  int comm_sz, my_rank;

  double t1, t2, delta;
  
  // Get and parse the program parameters
  getParams(argv, &flag, c, x, y, &width, &height, &maxiter, &image, &stats);

  // Allocate space for the image
  int *iterations = (int*)malloc( sizeof(int) * width * height );
  assert(iterations != NULL);
  
  // Start MPI
  MPI_Init(NULL, NULL);
  MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  
  // Begin process timer
  t1 = MPI_Wtime();
  
  /* compute set */
  int maxCount = parallelJulia(x, width, y, height, c, flag, maxiter, iterations, my_rank, comm_sz, MPI_COMM_WORLD);

  // Stop timer and compute time elapse
  t2 = MPI_Wtime();
  delta = t2 - t1;

  if (my_rank == 0)
  {
    /* save our picture for the viewer */
    printf("\nMaster process %d creating image...\n", my_rank);
    saveBMP(image, iterations, width, height);
    printf("\nFinished image creation\n");
  }

  // Wait for all processes to finish Julia computations
  MPI_Barrier(MPI_COMM_WORLD);

  // Open stats file
  MPI_File statsFile;

  if (MPI_File_open(MPI_COMM_WORLD, stats, MPI_MODE_CREATE|MPI_MODE_WRONLY, MPI_INFO_NULL, &statsFile) == MPI_SUCCESS) 
  {
    // Generate statistic string
    char message[100];
    sprintf(message, "process %d: max iterations reached = %d, time elapsed = %lf\n", my_rank, maxCount, delta);
  
    MPI_File_write_ordered(statsFile, message, strlen(message), MPI_CHAR, MPI_STATUS_IGNORE);

    MPI_File_close(&statsFile);
  }
  else printf("Problem opening file on process %d\n", my_rank);

  // Close MPI environment
  MPI_Finalize();
  
  // Free reserved memory
  free(iterations);

  return 0;
}
Exemplo n.º 29
0
TEST_P(COPY, scopy) {
    TestParams params;

    getParams(&params);
    copyCorrectnessTest<cl_float>(&params);
}
Exemplo n.º 30
0
const float HorizonBand::getScale() const
{
    osg::Vec3f params = getParams();
    return params[0];
}