当前位置: 首页>>代码示例>>C++>>正文


C++ SharedImage::getWidth方法代码示例

本文整理汇总了C++中SharedImage::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedImage::getWidth方法的具体用法?C++ SharedImage::getWidth怎么用?C++ SharedImage::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharedImage的用法示例。


在下文中一共展示了SharedImage::getWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
        }
开发者ID:khemanta,项目名称:OpenDaVINCI,代码行数:33,代码来源:LaneDetector.cpp

示例2: 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;
        }
开发者ID:PursuitOfHappiness,项目名称:Self-driving-car,代码行数:35,代码来源:LaneFollower.cpp

示例3: 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;
        }
开发者ID:khemanta,项目名称:OpenDaVINCI,代码行数:48,代码来源:VCR.cpp

示例4: 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;
                    	}
                    }
                }
            }
开发者ID:Duxiao777,项目名称:2013-mini-smart-vehicles,代码行数:19,代码来源:SharedImageViewerWidget.cpp

示例5: 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();
            		}
            	}
            }
开发者ID:Duxiao777,项目名称:2013-mini-smart-vehicles,代码行数:19,代码来源:SharedImageViewerWidget.cpp

示例6: drawScene

    void ChaseCar::drawScene() {
        static uint32_t frameCounter = 0;
        static clock_t start = clock();

        Container container = getKeyValueDataStore().get(opendlv::data::environment::EgoState::ID());
        m_egoState = container.getData<opendlv::data::environment::EgoState>();

        m_image = m_grabber->getNextImage();

        frameCounter++;

        // Share information about this image.
        if (m_image.get()) {
            SharedImage si;
            si.setWidth(m_image->getWidth());
            si.setHeight(m_image->getHeight());
            // TODO: Refactor me!
            si.setBytesPerPixel(3);
            si.setName("ChaseCar");
            si.setSize(si.getWidth() * si.getHeight() * si.getBytesPerPixel());

            Container c(si);
            getConference().send(c);
        }

        if ((frameCounter % 20) == 0) {
            clock_t end = clock();
            clock_t duration = end - start;
            double seconds = (1000.0 * duration) / CLOCKS_PER_SEC;
            seconds /= 1000.0;
            cerr << "FPS: " << (frameCounter / seconds) << endl;
            frameCounter = 0;
            start = clock();
        }

        m_grabber->delay();
    }
开发者ID:DKarlberg,项目名称:OpenDaVINCI,代码行数:37,代码来源:ChaseCar.cpp

示例7: main


//.........这里部分代码省略.........
        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.
                    {
                        Lock l(sharedImageMemory);
                        if (image == NULL) {
                            // Create the IplImage header data and access the shared memory for the actual image data. 
                            image = cvCreateImageHeader(cvSize(si.getWidth(), si.getHeight()), IPL_DEPTH_8U, si.getBytesPerPixel());

                            // Let the IplImage point to the shared memory containing the captured image.
                            image->imageData = static_cast<char*>(sharedImageMemory->getSharedMemory());
                        }
                    }

                    // Show the image using OpenCV.
                    
                    // if csv parameter is set
                    if(argc==4 || (argc==3 && string(argv[1]).compare("-l")!=0))
                    {
                        if(! row.readNextRow(file)) break;
                        while(row[0].compare("")==0)
                            if(! row.readNextRow(file)) break;
                        
                        sscanf(row[0].c_str(), "%d", &csvFN);
                        
                        if(frameNumber==csvFN)
                        {
                            Mat img = cvarrToMat(image);
                            
                        
                            frameMessage.str(string());
                            VPMessage.str(string());
                            sscanf(row[9].c_str(), "%d", &VPx);
                            sscanf(row[10].c_str(), "%d", &VPy);
                            
                            frameMessage<<"Frame "<<frameNumber;
                            VPMessage<<"Vanishing Point ("<<VPx<<","<<VPy<<")";
                            
                            setLabel(img, frameMessage.str(), cvPoint(30,45));
                            setLabel(img, VPMessage.str(), cvPoint(30,60));
开发者ID:se-research,项目名称:CaroloCup-CameraPlayback,代码行数:67,代码来源:CaroloCup-CameraPlayback.cpp


注:本文中的SharedImage::getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。