StorableMicroslice MicrosliceSource::get(uint64_t mc_index)
{
    if (mc_index >= start_index && mc_index < start_index + size()) {
        return _microslices[mc_index - start_index];
    } else {
        return {_desc(mc_index), {}};
    }
}
int main(int argc, char **argv)
{
    // Removes ORB related arguments
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    // Program options
    std::string register_servant;
    std::string proxy_reference;

    _po::options_description _desc("Proxy Server options");
    _desc.add_options()
        ("help,h", "produce help message")
        ("register-servant,r", _po::value< std::string >(&register_servant),
         "register the servant into the name service")
        ("proxy-reference,p", _po::value< std::string >(&proxy_reference),
         "forward received calls to another servant");

    _po::variables_map _vm;
    _po::store(_po::parse_command_line(argc, argv, _desc), _vm);
    _po::notify(_vm);

    if (_vm.count("help"))
    {
        std::cout << _desc << std::endl;
        return 0;
    }

    bool reference_is_ns_entry = false;
    // TODO

    // Name Service
    CosNaming::NamingContextExt_var nc;

    if (reference_is_ns_entry || !register_servant.empty())
    {
        try {
            CORBA::Object_var ncObj = orb->resolve_initial_references("NameService");

            nc = CosNaming::NamingContextExt::_narrow(ncObj);
        } catch(...) {
        }

        if (CORBA::is_nil(nc))
            std::cerr << "Name service unavailable!" << std::endl;
    }

    // Proxy reference
    prueba::Iface_var reference;

    if (!proxy_reference.empty())
    {
        CORBA::Object_var refObj;

        if (reference_is_ns_entry && !CORBA::is_nil(nc))
            refObj = nc->resolve_str(proxy_reference.c_str());
        else
            refObj = orb->string_to_object(proxy_reference.c_str());

        reference = prueba::Iface::_narrow(refObj);
    }

    // Servant
    prueba_Iface_impl _impl(reference.in());

    CORBA::Object_var rootPOAObj =
            orb->resolve_initial_references("RootPOA");

    PortableServer::POA_var rootPOA =
            PortableServer::POA::_narrow(rootPOAObj.in());

    PortableServer::POAManager_var manager = rootPOA->the_POAManager();

    PortableServer::ObjectId_var myObjID =
                rootPOA->activate_object(&_impl);

    CORBA::Object_var obj = rootPOA->servant_to_reference(&_impl);

    // Displaying reference
    CORBA::String_var ref = orb->object_to_string(obj);
    std::cout << ref << std::endl;

    // Registring servant
    CosNaming::Name_var name;

    if (!register_servant.empty() && !CORBA::is_nil(nc))
    {
        name = nc->to_name(register_servant.c_str());

        nc->rebind(name, obj);
    }

    /*PROTECTED REGION ID(prueba_Iface_impl_server::___main) ENABLED START*/
    /*PROTECTED REGION END*/

    // Running
    manager->activate();
    orb->run();

    // Unbinding servant
    if (!CORBA::is_nil(nc) && name)
        nc->unbind(name);

    return 0;
}
void MicrosliceSource::add(std::vector<uint8_t> content)
{
    auto mc_index = start_index + size();
    _microslices.emplace_back(_desc(mc_index), std::move(content));
}
Exemple #4
0
void CmdOptions::_parse_options(int ac, char* av[]) {
    try {
        po::options_description _desc("Some descriptions were taken from OpenCV documentation (http://opencv.itseez.com/modules/refman.html)\nAllowed options:");
        _desc.add_options()
            ("help,h", "Show this message.\n")
            ("input-file", po::value<std::string > (), "File with video material.\n")
            ("skipframes,S", po::value<int>(), "Number of frames to be skipped. Every skipframes-th frame will be processed.\nDefault value = 12\n")
            ("clip-len,L", po::value<int>(), "Single clip length in seconds.\nDefault value = 11\n")
            ("density", po::value<int>(), "Density of sampling grid - spacing (in pixels) between the samples.\nDefault value = 16\n")
            ("min-vect-len", po::value<int>(), "Minimal flow vector length to be assumed as movement.\nDefault value = 6\n")
            ("blind_top", po::value<int>(), "Blind field, from frame edge to arg.\nDefault value = 0\n")
            ("blind_left", po::value<int>(), "Blind field, from frame edge to arg.\nDefault value = 0\n")
            ("blind_right", po::value<int>(), "Blind field, from frame edge to arg.\nDefault value = 0\n")
            ("blind_bottom", po::value<int>(), "Blind field, from frame edge to arg.\nDefault value = 20\n")
            ("threads,T", po::value<int>(), "Set number of threads used for video processing.\nBest value is 1 thread per core thread (eg. Intel i7 has 4 cores and 8 threads, best value is 8). Warning: Video material is divided for each thread so you need at least 2x video size free hdd space.\nDefault value = 8\n")
            ("pyr-scale", po::value<double>(), "Parameter specifying the image scale (<1) to build pyramids for each image. \npyrScale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous one.\nDefault value = 0.5\n")
            ("levels", po::value<int>(), "Number of pyramid layers including the initial image. \nlevels=1 means that no extra layers are created and only the original images are used.\nDefault value = 3\n")
            ("winsize", po::value<int>(), "Averaging window size. \nLarger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field.\nDefault value = 15\n")
            ("iterations", po::value<int>(), "Number of iterations the algorithm does at each pyramid level.\nDefault value = 3\n")
            ("polyn", po::value<int>(), "Size of the pixel neighborhood used to find polynomial expansion in each pixel. \nLarger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field. \nTypically, polyN =5 or 7.\nDefault value = 5\n")
            ("poly-sigma", po::value<double>(), "Standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion. \nFor polyN=5 , you can set polySigma=1.1. For polyN=7, a good value would be polySigma=1.5\nDefault value = 1.2\n")
            ("use-farneback-gaussian,G", "Use the Gaussian filter instead of a box filter of the same size for optical flow estimation. \nUsually, this option gives z more accurate flow than with a box filter, at the cost of lower speed.\nNormally, winsize for a Gaussian window should be set to a larger value to achieve the same level of robustness.\nDefault value = false\n")
            ("verbose,V", "Be verbose.\nDefault value = false\n")
            ;

        po::positional_options_description p;
        p.add("input-file", -1);

        po::variables_map _vm;
        po::store(po::command_line_parser(ac, av).options(_desc).positional(p).run(), _vm);

        po::notify(_vm);

        if (_vm.count("help")) {
            std::cout << "Usage: ffb input.avi [options]\n";
            std::cout << _desc;
            exit(EXIT_SUCCESS);
        }

        if (_vm.count("input-file")) {
            this->_input_file = _vm["input-file"].as<std::string > ();
        }
        else {
            std::cerr << "No input file specified.\nUsage: ffb input.avi [options]\n";
            std::cout << _desc;
            exit(EXIT_FAILURE);
        }

        if (_vm.count("threads")) {
            this->_threads_number = _vm["threads"].as<int>();

            if (this->_threads_number < 1) {
                std::cerr << "No threads? Really? Give up, 1 thread is minimum...\n";
                exit(EXIT_FAILURE);
            }
        }

        if (_vm.count("pyr-scale")) {
            this->_pyrScale = _vm["pyr-scale"].as<double>();
        }

        if (_vm.count("levels")) {
            this->_levels = _vm["levels"].as<int>();
        }

        if (_vm.count("winsize")) {
            this->_winsize = _vm["winsize"].as<int>();
        }

        if (_vm.count("iterations")) {
            this->_iterations = _vm["iterations"].as<int>();
        }

        if (_vm.count("polyn")) {
            this->_polyN = _vm["polyn"].as<int>();
        }

        if (_vm.count("density")) {
            this->_density = _vm["density"].as<int>();
        }

        if (_vm.count("blind_top")) {
            this->_blind_top = _vm["blind_top"].as<int>();
        }

        if (_vm.count("blind_left")) {
            this->_blind_top = _vm["blind_top"].as<int>();
        }

        if (_vm.count("blind_right")) {
            this->_blind_right = _vm["blind_right"].as<int>();
        }

        if (_vm.count("blind_bottom")) {
            this->_blind_bottom = _vm["blind_bottom"].as<int>();
        }

        if (_vm.count("min-vect-len")) {
            this->_min_vector_len = _vm["min-vect-len"].as<int>();
        }

        if (_vm.count("skipframes")) {
            this->_skipframes = _vm["skipframes"].as<int>();
        }

        if (_vm.count("clip-len")) {
            this->_clip_len = _vm["clip-len"].as<int>();
        }

        if (_vm.count("poly-sigma")) {
            this->_polySigma = _vm["poly-sigma"].as<double>();
        }

        if (_vm.count("use-farneback-gaussian")) {
            this->_use_farneback_gaussian = true;
        }

        if (_vm.count("verbose")) {
            this->_verbose = true;
        }
    }
    catch (std::exception& e) {
        std::cerr << "Error: " << e.what() << "\n";
        exit(EXIT_FAILURE);
    }
    catch (...) {
        std::cerr << "Exception of unknown type!\n";
        exit(EXIT_FAILURE);
    }

}