Пример #1
0
/// dvox: A batch voxelizer for unstructured point clouds
int main(int argc, char* argv[])
{
    Imath::V3d boundMin = Imath::V3d(0);
    double rootNodeWidth = 1000;
    float pointRadius = 0.2f;
    int brickRes = 8;
    double leafNodeWidth = 2.5;

    double dbTileSize = 100;
    double dbCacheSize = 100;

    bool logProgress = false;
    int logLevel = Logger::Info;

    ArgParse::ArgParse ap;

    ap.options(
        "dvox - voxelize unstructured point clouds (version " DISPLAZ_VERSION_STRING ")\n"
        "\n"
        "Usage: dvox input1 [input2 ...] output\n"
        "\n"
        "input can be .las or .pointdb\n"
        "output can be .pointdb or .hcloud",
        "%*", storePositionalArg, "",

        "<SEPARATOR>", "\nVoxelization Options:",
        "-bound %F %F %F %F", &boundMin.x, &boundMin.y, &boundMin.z, &rootNodeWidth,
                                        "Bounding box for hcloud (min_x min_y min_z width)",
        "-pointradius %f", &pointRadius, "Assumed radius of points used during voxelization",
        "-brickresolution %d", &brickRes, "Resolution of octree bricks",
        "-leafnoderadius %F", &leafNodeWidth, "Desired width for octree leaf nodes",

        "<SEPARATOR>", "\nPoint Database options:",
        "-dbtilesize %F", &dbTileSize, "Tile size of temporary point database",
        "-dbcachesize %F", &dbCacheSize, "In-memory cache size for database in MB (default 100 MB)",

        "<SEPARATOR>", "\nInformational options:",
        "-loglevel %d",  &logLevel,    "Logger verbosity (default 3 = info, greater is more verbose)",
        "-progress",     &logProgress, "Log processing progress",

        NULL
    );

    StreamLogger logger(std::cerr);

    if (ap.parse(argc, const_cast<const char**>(argv)) < 0)
    {
        ap.usage();
        logger.error("%s", ap.geterror());
        return EXIT_FAILURE;
    }
    if (argc == 1)
    {
        ap.usage();
        return EXIT_FAILURE;
    }

    logger.setLogLevel(Logger::LogLevel(logLevel));
    logger.setLogProgress(logProgress);

    try
    {
        if (g_positionalArgs.size() < 2)
        {
            logger.error("Expected at least two positional arguments");
            ap.usage();
            return EXIT_FAILURE;
        }
        std::string outputPath = g_positionalArgs.back();
        std::vector<std::string> inputPaths(g_positionalArgs.begin(),
                                            g_positionalArgs.end()-1);
        if (endswith(outputPath.toLower(), ".pointdb"))
        {
            convertLasToPointDb(outputPath, inputPaths,
                                Imath::Box3d(), dbTileSize, logger);
        }
        else
        {
            if (!endswith(g_positionalArgs[0].toLower(), ".pointdb") ||
                inputPaths.size() != 1)
            {
                logger.error("Need exactly one input .pointdb file");
                return EXIT_FAILURE;
            }
            if (!endswith(outputPath.toLower(), ".hcloud"))
            {
                logger.error("Expected .hcloud file as output path");
                return EXIT_FAILURE;
            }
            SimplePointDb pointDb(inputPaths[0],
                                  (size_t)(dbCacheSize*1024*1024),
                                  logger);

            int leafDepth = (int)floor(log(rootNodeWidth/leafNodeWidth)/log(2) + 0.5);
            logger.info("Leaf node width = %.3f", rootNodeWidth / (1 << leafDepth));
            std::ofstream outputFile(outputPath);
            voxelizePointCloud(outputFile, pointDb, pointRadius,
                               boundMin, rootNodeWidth,
                               leafDepth, brickRes, logger);
        }
    }
    catch (std::exception& e)
    {
        logger.error("Caught exception: %s", e.what());
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}
Пример #2
0
void searchInputFiles()
{
  QStrList exclPatterns;
  bool alwaysRecursive = true;
  StringDict excludeNameDict(1009);
  excludeNameDict.setAutoDelete(TRUE);

  // gather names of all files in the include path
  QStrList includePathList;
  includePathList.append("C:\\Projects\\proj");
  char *s=includePathList.first();
  while (s)
  {
    QStrList pl;
	pl.append("*.h");
	pl.append("*.cpp");
    readFileOrDirectory(s,0,includeNameDict,0,&pl,
                        &exclPatterns,0,0,
                        alwaysRecursive);
    s=includePathList.next(); 
  }

  /**************************************************************************
   *             Determine Input Files                                      *
   **************************************************************************/

  QDict<void> *killDict = new QDict<void>(10007);
  QStrList inputList;
  inputList.append("C:\\Projects\\proj");
  g_inputFiles.setAutoDelete(TRUE);
  s=inputList.first();
  QDict<void>      inputPaths(1009);
  while (s)
  {
    QCString path=s;
    uint l = path.length();
    if (l>0)
    {
      // strip trailing slashes
      if (path.at(l-1)=='\\' || path.at(l-1)=='/') path=path.left(l-1);

      QStrList pl;
	  pl.append("*.h");
	  pl.append("*.cpp");
      readFileOrDirectory(
          path,
          inputNameList,
          inputNameDict,
          &excludeNameDict,
          &pl,
          &exclPatterns,
          &g_inputFiles,0,
          alwaysRecursive,
          TRUE,
          killDict,
          &inputPaths);
    }
    s=inputList.next();
  }
  delete killDict;
}
Пример #3
0
void CTCDecoderLayer::runForwardImplementation(Bundle& bundle)
{
    auto& inputActivationsVector  = bundle[ "inputActivations"].get<MatrixVector>();
    auto& outputActivationsVector = bundle["outputActivations"].get<MatrixVector>();

    assert(inputActivationsVector.size() == 1);

    auto inputActivations = inputActivationsVector.back();

    saveMatrix("inputActivations", inputActivations);

    auto beamSearchOutputSize = matrix::getBeamSearchOutputSize(
        inputActivations.size(), _implementation->getBeamSize());

    size_t miniBatchSize = inputActivations.size()[inputActivations.size().size() - 2];
    size_t timesteps     = inputActivations.size()[inputActivations.size().size() - 1];

    Matrix inputPaths({_implementation->getBeamSize(), miniBatchSize, timesteps},
        inputActivations.precision());
    Matrix outputActivations(beamSearchOutputSize, inputActivations.precision());
    Matrix outputActivationWeights({_implementation->getBeamSize(), miniBatchSize},
        inputActivations.precision());

    matrix::ctcBeamSearch(outputActivationWeights, inputPaths, outputActivations,
        inputActivations, _implementation->getBeamSize());

    reshapeOutputActivations(outputActivations, inputActivations.size(),
        _implementation->getBeamSize());

    bundle["outputActivationWeights"] = outputActivationWeights;

    saveMatrix("outputActivationWeights", outputActivationWeights);
    saveMatrix("inputPaths",              inputPaths);

    if(util::isLogEnabled("CTCDecoderLayer::Detail"))
    {
        util::log("CTCDecoderLayer::Detail") << "  output activation: "
            << outputActivations.debugString();
        util::log("CTCDecoderLayer::Detail") << "  input paths: "
            << inputPaths.debugString();
        util::log("CTCDecoderLayer::Detail") << "  output activation weights: "
            << outputActivationWeights.debugString();
    }
    else
    {
        util::log("CTCDecoderLayer") << "  output activation size: "
            << outputActivations.shapeString() << "\n";
        util::log("CTCDecoderLayer") << "  input paths: "
            << inputPaths.shapeString() << "\n";
        util::log("CTCDecoderLayer") << "  output activation weights: "
            << outputActivationWeights.shapeString() << "\n";
    }

    _implementation->saveInputLabels(   bundle["referenceLabels"].get<LabelVector>());
    _implementation->saveInputTimesteps(bundle["inputTimesteps" ].get<IndexVector>());

    outputActivationsVector.push_back(outputActivations);

    expandLabels(bundle, _implementation->getBeamSize());

    if(_implementation->hasCostFunction())
    {
        auto inputTimesteps = _implementation->getInputTimesteps();
        auto inputLabels    = _implementation->getInputLabels();

        computeCtcCosts(bundle, _implementation->getCostFunctionName(),
            _implementation->getCostFunctionWeight(),
            inputActivations, inputLabels, inputTimesteps);
    }
}