本文整理汇总了C++中SharedImage::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedImage::getName方法的具体用法?C++ SharedImage::getName怎么用?C++ SharedImage::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedImage
的用法示例。
在下文中一共展示了SharedImage::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextContainer
void SharedImageViewerWidget::nextContainer(Container &c) {
if (c.getDataType() == Container::SHARED_IMAGE) {
SharedImage si = c.getData<SharedImage>();
if ( ( (si.getWidth() * si.getHeight()) > 0) && (si.getName().size() > 0) ) {
// Check if this shared image is already in the list.
vector<string>::iterator result = std::find(m_listOfAvailableSharedImages.begin(), m_listOfAvailableSharedImages.end(), si.getName());
if (result == m_listOfAvailableSharedImages.end()) {
m_listOfAvailableSharedImages.push_back(si.getName());
QString item = QString::fromStdString(si.getName());
m_list->addItem(item);
// Store for further usage.
m_mapOfAvailableSharedImages[si.getName()] = si;
}
}
}
}
示例2: readSharedImage
bool VCR::readSharedImage(Container &c) {
bool retVal = false;
if (c.getDataType() == Container::SHARED_IMAGE) {
SharedImage si = c.getData<SharedImage> ();
// Check if we have already attached to the shared memory.
if (!m_hasAttachedToSharedImageMemory) {
m_sharedImageMemory
= core::wrapper::SharedMemoryFactory::attachToSharedMemory(
si.getName());
}
// Check if we could successfully attach to the shared memory.
if (m_sharedImageMemory->isValid()) {
//cerr << "Got image: LOG 0.2 " << si.toString() << endl;
// Lock the memory region to gain exclusive access. REMEMBER!!! DO NOT FAIL WITHIN lock() / unlock(), otherwise, the image producing process would fail.
m_sharedImageMemory->lock();
{
// Here, do something with the image. For example, we simply show the image.
const uint32_t numberOfChannels = 3;
// For example, simply show the image.
if (m_image == NULL) {
m_image = cvCreateImage(cvSize(si.getWidth(),
si.getHeight()), IPL_DEPTH_8U, numberOfChannels);
}
// Copying the image data is very expensive...
if (m_image != NULL) {
memcpy(m_image->imageData,
m_sharedImageMemory->getSharedMemory(),
si.getWidth() * si.getHeight() * numberOfChannels);
}
}
// Release the memory region so that the image produce (i.e. the camera for example) can provide the next raw image data.
m_sharedImageMemory->unlock();
// Mirror the image.
cvFlip(m_image, 0, -1);
retVal = true;
}
}
return retVal;
}
示例3: readSharedImage
bool LaneDetector::readSharedImage(Container &c) {
bool retVal = false;
if (c.getDataType() == Container::SHARED_IMAGE) {
SharedImage si = c.getData<SharedImage> ();
// Check if we have already attached to the shared memory containing the image from the virtual camera.
if (!m_hasAttachedToSharedImageMemory) {
m_sharedImageMemory = core::wrapper::SharedMemoryFactory::attachToSharedMemory(si.getName());
}
// Check if we could successfully attach to the shared memory.
if (m_sharedImageMemory->isValid()) {
// Lock the memory region to gain exclusive access using a scoped lock.
Lock l(m_sharedImageMemory);
if (m_image == NULL) {
m_image = cvCreateImage(cvSize(si.getWidth(), si.getHeight()), IPL_DEPTH_8U, si.getBytesPerPixel());
}
// Example: Simply copy the image into our process space.
if (m_image != NULL) {
memcpy(m_image->imageData, m_sharedImageMemory->getSharedMemory(), si.getWidth() * si.getHeight() * si.getBytesPerPixel());
}
// Mirror the image.
cvFlip(m_image, 0, -1);
retVal = true;
}
}
return retVal;
}
示例4: readSharedImage
bool LaneFollower::readSharedImage(Container &c) {
bool retVal = false;
if (c.getDataType() == odcore::data::image::SharedImage::ID()) {
SharedImage si = c.getData<SharedImage> ();
// Check if we have already attached to the shared memory.
if (!m_hasAttachedToSharedImageMemory) {
m_sharedImageMemory = odcore::wrapper::SharedMemoryFactory::attachToSharedMemory(si.getName());
}
// Check if we could successfully attach to the shared memory.
if (m_sharedImageMemory->isValid()) {
// Lock the memory region to gain exclusive access using a scoped lock.
Lock l(m_sharedImageMemory);
const uint32_t numberOfChannels = 3;
// For example, simply show the image.
if (m_image.empty()) {
m_image.create(cv::Size(si.getWidth(), si.getHeight()), CV_8UC3);
}
// Copying the image data is very expensive...
if (!m_image.empty()) {
memcpy(m_image.data, m_sharedImageMemory->getSharedMemory(), si.getWidth() * si.getHeight() * numberOfChannels);
}
// Mirror the image.
cv::flip(m_image,m_image,-1); //only use in simulator
retVal = true;
}
}
return retVal;
}
示例5: main
int32_t main(int32_t argc, char **argv)
{
uint32_t retVal = 0;
int recIndex=1;
bool log=false;
if((argc != 2 && argc != 3 && argc != 4) || (argc==4 && string(argv[1]).compare("-l")!=0))
{
errorMessage(string(argv[0]));
retVal = 1;
}
else if(argc==2 && string(argv[1]).compare("-h")==0)
{
helpMessage(string(argv[0]));
retVal = 0;
}
else
{
// if -l option is set
if(argc==4 || (argc==3 && string(argv[1]).compare("-l")==0))
{
++recIndex;
log=true;
}
// Use command line parameter as file for playback;
string recordingFile(argv[recIndex]);
stringstream recordingFileUrl;
recordingFileUrl << "file://" << recordingFile;
// Location of the recording file.
URL url(recordingFileUrl.str());
// Do we want to rewind the stream on EOF?
const bool AUTO_REWIND = false;
// Size of the memory buffer that should fit at least the size of one frame.
const uint32_t MEMORY_SEGMENT_SIZE = 1024 * 768;
// Number of memory segments (one is enough as we are running sychronously).
const uint32_t NUMBER_OF_SEGMENTS = 1;
// Run player in synchronous mode without data caching in background.
const bool THREADING = false;
// Construct the player.
Player player(url, AUTO_REWIND, MEMORY_SEGMENT_SIZE, NUMBER_OF_SEGMENTS, THREADING);
// The next container from the recording.
Container nextContainer;
// Using OpenCV's IplImage data structure to simply playback the data.
IplImage *image = NULL;
// Create the OpenCV playback window.
cvNamedWindow("CaroloCup-CameraPlayback", CV_WINDOW_AUTOSIZE);
// This flag indicates whether we have attached already to the shared
// memory containing the sequence of captured images.
bool hasAttachedToSharedImageMemory = false;
// Using this variable, we will access the captured images while
// also having convenient automated system resource management.
SharedPointer<SharedMemory> sharedImageMemory;
ifstream file(argv[recIndex+1]);
CSVRow row;
// read out the header row
row.readNextRow(file);
uint32_t frameNumber=1, csvFN;
int32_t VPx,VPy,BLx,BLy,BRx,BRy,TLx,TLy,TRx,TRy;
stringstream frameMessage;
stringstream VPMessage;
frameMessage.str(string());
VPMessage.str(string());
bool fbf=false;
// Main data processing loop.
while (player.hasMoreData()) {
// Read next entry from recording.
nextContainer = player.getNextContainerToBeSent();
// Data type SHARED_IMAGE contains a SharedImage data structure that
// provides meta-information about the captured image.
if (nextContainer.getDataType() == Container::SHARED_IMAGE) {
// Read the data structure to retrieve information about the image.
SharedImage si = nextContainer.getData<SharedImage>();
// Check if we have already attached to the shared memory.
if (!hasAttachedToSharedImageMemory) {
sharedImageMemory = SharedMemoryFactory::attachToSharedMemory(si.getName());
// Toggle the flag as we have now attached to the shared memory.
hasAttachedToSharedImageMemory = true;
}
// Check if we could successfully attach to the shared memory.
if (sharedImageMemory->isValid()) {
// Using a scoped lock to get exclusive access.
{
//.........这里部分代码省略.........
示例6: selectedSharedImage
void SharedImageViewerWidget::selectedSharedImage(QListWidgetItem *item) {
if (item != NULL) {
// Retrieve stored shared image.
SharedImage si = m_mapOfAvailableSharedImages[item->text().toStdString()];
if ( (si.getWidth() * si.getHeight()) > 0 ) {
Lock l(m_sharedImageMemoryMutex);
cerr << "Using shared image: " << si.toString() << endl;
setWindowTitle(QString::fromStdString(si.toString()));
m_sharedImageMemory = core::wrapper::SharedMemoryFactory::attachToSharedMemory(si.getName());
m_sharedImage = si;
// Remove the selection box.
m_list->hide();
}
}
}