Esempio n. 1
0
void
MultiCameraReader::readFromFile( std::ifstream *file,
                              const std::string &format,
                              orcaice::Context context,
                              orca::MultiCameraDescriptionPtr &obj )
{
    descr_ = new orca::MultiCameraDescription();
    if ( format=="ice" )
    {
        orcalog::IceReadHelper helper( context.communicator(), file );
        ice_readMultiCameraDescription( helper.stream_, obj );
        helper.read();
    }
    else if ( format=="jpeg" || format=="bmp" || format=="avi")
    {
#ifndef OPENCV_FOUND
        std::stringstream infostring;
        infostring << "Images can only be replayed in '" << format << "' format if you have OpenCV.";
        context.tracer().info( infostring.str() );
        context.tracer().info( "Please have a look at the documentation for installing OpenCV." );
        std::stringstream errorstring;
        errorstring << "Logger: '"<< format <<"' format not supported because OpenCV is not installed.";
        throw orcalog::FormatNotSupportedException( ERROR_INFO, errorstring.str() );
#endif

        // Populate the description with data from the file
        std::string line;
        std::getline( *file, line );

        std::stringstream ss( line );
        fromLogString( ss, descr_ );

        // Point the descriptor pointer to our copy of it
        obj = descr_;
    }
    else
    {
        stringstream ss;
        ss <<  "can't handle format: " << format;
        throw orcalog::FormatNotSupportedException( ERROR_INFO, ss.str() );
    }

    // Now that we know the size, initialise the data storage
    initDataStorage();

}
Esempio n. 2
0
void
MultiCameraWriter::logToFile( std::ofstream *file, const std::string &format, orcaice::Context context, const orca::MultiCameraDescriptionPtr &obj)
{
    if ( format=="ice" ){
        orcalog::IceWriteHelper helper( context.communicator() );
        ice_writeMultiCameraDescription( helper.stream_, obj );
        helper.write( file );
    }
    else if ( format=="jpeg" || format == "bmp" ||  format=="avi") {
        //Log the MultiCamera Description to an ascii file
        (*file) << toLogString(obj) << endl;
    }
    else{
        stringstream ss;
        ss << "can't handle format: " << format;
        throw orcalog::FormatNotSupportedException( ERROR_INFO, ss.str() );
    }

}
Esempio n. 3
0
Ice::ObjectPrx
getComponentAdmin( const orcaice::Context& context, const orca::FQComponentName& fqName )
{    
    orca::FQComponentName resolvedFqname = orcaice::resolveLocalPlatform( context, fqName );

    Ice::CommunicatorPtr ic = context.communicator();
    assert( ic );

    Ice::LocatorPrx locatorPrx = ic->getDefaultLocator();
    
    Ice::Identity adminId = toAdminIdentity( resolvedFqname );
    Ice::ObjectPrx adminPrx;

    try {
        adminPrx = locatorPrx->findObjectById( adminId );
    } 
    catch ( const Ice::Exception& ) {
        // what do we do?
    }

    return adminPrx;
}
Esempio n. 4
0
IceGrid::QueryPrx 
getDefaultQuery( const orcaice::Context& context )
{
    Ice::CommunicatorPtr ic = context.communicator();
    assert( ic );

    Ice::ObjectPrx locatorPrx = ic->getDefaultLocator();

    Ice::Identity locatorId = locatorPrx->ice_getIdentity();
    Ice::Identity queryId;
    queryId.category = locatorId.category;
    queryId.name = "Query";

    Ice::ObjectPrx objPrx = ic->stringToProxy( ic->identityToString( queryId ) );
            
    IceGrid::QueryPrx queryPrx;

    try {
//         objPrx->ice_ping();
//         string address = orcacm::connectionToRemoteAddress( queryPrx->ice_getConnection()->toString() );

//         std::ostringstream os;
//         os<<"Registry ping successful: "<<data.address;
//         context.tracer().debug( os.str() );

        queryPrx = IceGrid::QueryPrx::checkedCast( objPrx );
    } 
    catch ( const Ice::Exception& e ) {
        // what do we do?
        ostringstream os;
        os << "(while looking for IceGrid Query interface) :"<<e.what();
        context.tracer().warning( os.str() );
    }

    return queryPrx;
}
Esempio n. 5
0
void
MultiCameraReader::readFromFile( std::ifstream *file,
                              const std::string &format,
                              orcaice::Context context,
                              orca::MultiCameraDataPtr &obj )
{
    if ( format=="ice" )
    {
        orcalog::IceReadHelper helper( context.communicator(), file );
        ice_readMultiCameraData( helper.stream_, obj );
        helper.read();
    }
    else if ( format=="jpeg" || format == "bmp" )
    {

#ifndef OPENCV_FOUND
        std::stringstream infostring;
        infostring << "Images can only be replayed in '"<< format <<"' format if you have OpenCV.";
        context.tracer().info( infostring.str() );
        context.tracer().info( "Please have a look at the documentation for installing OpenCV." );
        std::stringstream errorstring;
        errorstring << "Logger: '"<< format << "' format not supported because OpenCV is not installed.";
        throw orcalog::FormatNotSupportedException( ERROR_INFO, errorstring.str() );
#endif

        // Pull the next line from the data log file
        std::string line;
        std::getline( *file, line );

        // Fill the MultiCameraDataObject with the data
        std::stringstream ss( line );
        fromLogString( ss, data_ );

        // Load the correct images using the filenames provided
        loadImageData( ss, data_);

        // Point the descriptor pointer to our copy
        obj = data_;
    }
    else if ( format=="avi" )
    {

#ifndef OPENCV_FOUND
            context.tracer().info( "Data can only be replayed in 'avi' format if you have OpenCV." );
            context.tracer().info( "Please have a look at the documentation for installing OpenCV." );
            throw orcalog::FormatNotSupportedException( ERROR_INFO, "Logger: 'avi' format not supported because OpenCV is not installed." );
#endif

        // Pull the next line from the data log file
        std::string line;
        std::getline( *file, line );

        // Fill the MultiCameraDataObject with the data
        std::stringstream ss( line );
        fromLogString( ss, data_ );

        // Load the correct images using the filenames provided
        loadVideoData( ss, data_ );

        // Point the descriptor pointer to our copy
        obj = data_;
    }
    else
    {
        stringstream ss;
        ss <<  "can't handle format: " << format;
        throw orcalog::FormatNotSupportedException( ERROR_INFO, ss.str() );
    }
}
Esempio n. 6
0
void
MultiCameraWriter::logToFile( std::ofstream *file, const std::string &format, orcaice::Context context, const orca::MultiCameraDataPtr &obj)
{
        if ( format == "ice" ){
            orcalog::IceWriteHelper helper( context.communicator() );
            ice_writeMultiCameraData( helper.stream_, obj );
            helper.write( file );
        }
        else if ( format=="jpeg" ){
             // write object meta data into a ascii file
             (*file) << toLogString(obj);

             // For each image in MultiCameraDatPtr, write it to disk
             for (unsigned int i = 0; i < obj->cameraDataVector.size(); ++i)
             {
                 // generate image filename (different file for each image)
                 std::stringstream filename;
                 filename << ".//" << directoryPrefix_ << "//" << "cam" << i << "_image"
                        << std::setw(5) << std::setfill('0') << dataCounter_ << ".jpeg";
                 std::string outputname;
                 outputname = filename.str();

                 // Write the outputted filename to the logfile as well
                 (*file) << " " << outputname;

                // the images are saved as individual jpegs
                writeCameraDataAsFile(obj, outputname, i);
            }
            // Make sure we put in a newline
            (*file) << endl;

        }
        else if ( format=="bmp" ){
            // write object meta data into a ascii file
            (*file) << toLogString(obj);

            // For each image in MultiCameraDatPtr, write it to disk
            for (unsigned int i = 0; i < obj->cameraDataVector.size(); ++i)
            {
                // generate image filename (different file for each image)
                std::stringstream filename;
                filename << ".//" << directoryPrefix_ << "//" << "cam" << i << "_image"
                        << std::setw(5) << std::setfill('0') << dataCounter_ << ".bmp";
                std::string outputname;
                outputname = filename.str();

                // Write the outputted filename to the logfile as well
                (*file) << " " <<outputname;
                
                // the images are saved as individual bitmaps
                writeCameraDataAsFile(obj, outputname, i);
            }

            // Make sure we put in a newline
            (*file) << endl;
        }
        else if (format =="avi") {
            // write object meta data into a ascii file
            (*file) << toLogString(obj);

            // For each image in MultiCameraDatPtr, write it to disk
            for (unsigned int i = 0; i < obj->cameraDataVector.size(); ++i)
            {
                // generate image filename. This will be the same for each video,
                // but is important for the logplayer to know what the filename is.
                // Also allows for future enhancements to split the video file into
                // manageable pieces
                std::stringstream filename;
                filename << ".//" << directoryPrefix_ << "//" << "cam" << i << "_avi_video.avi";
                std::string outputname = filename.str();

                // Write the outputted filename to the logfile as well
                (*file) << " " << outputname;

                 // the images are saved as uncompressed video into separate files
                 writeCameraDataAsVideo(obj, i);
            }
            // Make sure we put in a newline
            (*file) << endl;
        }
        else{
            stringstream ss;
            ss << "can't handle format: " << format;
            throw orcalog::FormatNotSupportedException( ERROR_INFO, ss.str() );
        }
        // Increment output image number
        dataCounter_++;
}