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


C++ SharedImage类代码示例

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


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

示例1: covariancefunction

double GazeTracker::covariancefunction(SharedImage const& im1, 
				       SharedImage const& im2)
{
    const double sigma = 100.0;
    const double lscale = 4000.0;
    return sigma*sigma*exp(-imagedistance(im1.get(),im2.get())/(2*lscale*lscale));
}
开发者ID:alc1218,项目名称:OpenGazer,代码行数:7,代码来源:GazeTracker.cpp

示例2: if

void
ShadowImageLayerOGL::Swap(const SharedImage& aNewFront,
                          SharedImage* aNewBack)
{
  if (!mDestroyed) {
    if (aNewFront.type() == SharedImage::TSharedImageID) {
      // We are using ImageBridge protocol. The image data will be queried at render
      // time in the parent side.
      PRUint64 newID = aNewFront.get_SharedImageID().id();
      if (newID != mImageContainerID) {
        mImageContainerID = newID;
        mImageVersion = 0;
      }
    } else if (aNewFront.type() == SharedImage::TSurfaceDescriptor) {
      AutoOpenSurface surf(OPEN_READ_ONLY, aNewFront.get_SurfaceDescriptor());
      gfxIntSize size = surf.Size();
      if (mSize != size || !mTexImage ||
          mTexImage->GetContentType() != surf.ContentType()) {
        Init(aNewFront);
      }
      // XXX this is always just ridiculously slow
      nsIntRegion updateRegion(nsIntRect(0, 0, size.width, size.height));
      mTexImage->DirectUpdate(surf.Get(), updateRegion);
    } else {
      const YUVImage& yuv = aNewFront.get_YUVImage();
      UploadSharedYUVToTexture(yuv);
    }
  }

  *aNewBack = aNewFront;
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:31,代码来源:ImageLayerOGL.cpp

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

示例4: clock

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

        Container container = getKeyValueDataStore().get(Container::EGOSTATE);
        m_egoState = container.getData<hesperia::data::environment::EgoState>();
        m_image = m_grabber->getNextImage();

        frameCounter++;

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

            Container c(Container::SHARED_IMAGE, 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:Duxiao777,项目名称:2013-mini-smart-vehicles,代码行数:35,代码来源:CamGen.cpp

示例5: 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

示例6: cvNamedWindow

void SharedImageSequence::GetSharedImageSequencePowerCube(libCameraSensors::AbstractRangeImagingSensor* RangeCam, libCameraSensors::AbstractColorCamera* ColorCam, const CvSize& SharedImageSize, int DegreeOffset)
{

#ifndef __USE_POWERCUBE__
	std::cout << "Error: you have to enable the preprocessor symbol __USE_POWERCUBE__" << std::endl;
#endif

#ifdef __USE_POWERCUBE__
	cvNamedWindow(m_CoordWinName.c_str());
	cvNamedWindow(m_ColorWinName.c_str());
	char c=-1;
	ipa_utils::PowerCube powercube;
	powercube.Init();
	powercube.Open();
	powercube.DoHoming();
			
	// Rotate and capture

	unsigned int rotationIncrement = DegreeOffset;
	for(unsigned int degree = 0; degree < 360; degree += rotationIncrement)
	{
		
		if(!cvGetWindowHandle(m_CoordWinName.c_str()) || !cvGetWindowHandle(m_ColorWinName.c_str()))
		{
			break;
		}
		
		powercube.Rotate(rotationIncrement);
		
		SharedImage SImg;//(m_SharedImageSize);//, m_CameraSensorsIniDirectory);
		//SImg.Init(SharedImageSize);
	#ifndef __USE_SHAREDIMAGE_JBK__
		SImg.GetImagesFromSensors(RangeCam, ColorCam, SharedImageDefaultSize);
	#endif
	#ifdef __USE_SHAREDIMAGE_JBK__
		SImg.GetImagesFromSensors(RangeCam, ColorCam);
	#endif
		SImg.DisplayCoord(m_CoordWinName);
		SImg.DisplayShared(m_ColorWinName);
		push_back(SImg);

		c = cvWaitKey(100);
		if(c=='q' || c=='Q')
		{
			break;
		}

		std::cout << "SharedImageSequence::GetSharedImageSequence: ... one image sucessfully acquired." << std::endl;
	}
	cvDestroyAllWindows();
	powercube.Close();
#endif // __USE_POWERCUBE__
}
开发者ID:Yanzqing,项目名称:cob_object_perception,代码行数:53,代码来源:SharedImageSequence.cpp

示例7: autoSurf

bool
ShadowImageLayerOGL::Init(const SharedImage& aFront)
{
  if (aFront.type() == SharedImage::TSurfaceDescriptor) {
    SurfaceDescriptor surface = aFront.get_SurfaceDescriptor();
    if (surface.type() == SurfaceDescriptor::TSharedTextureDescriptor) {
      SharedTextureDescriptor texture = surface.get_SharedTextureDescriptor();
      mSize = texture.size();
      mSharedHandle = texture.handle();
      mShareType = texture.shareType();
      mInverted = texture.inverted();
    } else {
      AutoOpenSurface autoSurf(OPEN_READ_ONLY, surface);
      mSize = autoSurf.Size();
      mTexImage = gl()->CreateTextureImage(nsIntSize(mSize.width, mSize.height),
                                           autoSurf.ContentType(),
                                           LOCAL_GL_CLAMP_TO_EDGE,
                                           mForceSingleTile
                                            ? TextureImage::ForceSingleTile
                                            : TextureImage::NoFlags);
    }
  } else {
    YUVImage yuv = aFront.get_YUVImage();

    AutoOpenSurface surfY(OPEN_READ_ONLY, yuv.Ydata());
    AutoOpenSurface surfU(OPEN_READ_ONLY, yuv.Udata());

    mSize = surfY.Size();
    mCbCrSize = surfU.Size();

    if (!mYUVTexture[0].IsAllocated()) {
      mYUVTexture[0].Allocate(gl());
      mYUVTexture[1].Allocate(gl());
      mYUVTexture[2].Allocate(gl());
    }

    NS_ASSERTION(mYUVTexture[0].IsAllocated() &&
                 mYUVTexture[1].IsAllocated() &&
                 mYUVTexture[2].IsAllocated(),
                 "Texture allocation failed!");

    gl()->MakeCurrent();
    SetClamping(gl(), mYUVTexture[0].GetTextureID());
    SetClamping(gl(), mYUVTexture[1].GetTextureID());
    SetClamping(gl(), mYUVTexture[2].GetTextureID());
    return true;
  }
  return false;
}
开发者ID:Web5design,项目名称:mozilla-central,代码行数:49,代码来源:ImageLayerOGL.cpp

示例8: clear

int SharedImageSequence::LoadSharedImageSequence(const std::string& filename, unsigned int Limit, int k)
{
	clear();
	std::cout << "Loading image sequence " << filename << "\n";
	std::stringstream FileNameStream;
	FileNameStream << filename << m_InfFileAttachment;
	std::ifstream f((FileNameStream.str()).c_str());
	if(!f.is_open())
	{
		std::cout << "SharedImageSequence::LoadSharedImageSequence: Error while opening file " 
			      << FileNameStream.str().c_str() << ".\n";
		return RET_FAILED;
	}

	/// Read number of images that are stored on disk
	int s=0; f >> s; s=intmin(Limit, s);

	std::cout << "SharedImageSequence::LoadSharedImageSequence: Loading ";
	std::list<SharedImage> listSI;
	int i;
	for(i=0; i<s; i+=k)
	{
		std::stringstream FileNameStream2;
		FileNameStream2 << filename << m_Spacing << i;
		
		SharedImage Tmp;
		
		/// Load the single images (coordinate and shared image) from disk
		if(Tmp.LoadSharedImage(FileNameStream2.str())==RET_FAILED) return RET_FAILED;
		push_back(Tmp);
		//listSI.push_back(Tmp);
		std::cout << i << " ";
	}

	//	std::list<SharedImage>::iterator it;
	//	(*this).assign(s, SharedImage());
	//	i=0;
	//	for(it=listSI.begin(); it!=listSI.end(); it++)
	//	{
	//		(*this)[i]=*it;
	//		i++;
	//	}

	std::cout << "\n";

	return RET_OK;
}
开发者ID:Yanzqing,项目名称:cob_object_perception,代码行数:47,代码来源:SharedImageSequence.cpp

示例9: gl

bool
ShadowImageLayerOGL::Init(const SharedImage& aFront)
{
  if (aFront.type() == SharedImage::TSurfaceDescriptor) {
    SurfaceDescriptor desc = aFront.get_SurfaceDescriptor();
    nsRefPtr<gfxASurface> surf =
      ShadowLayerForwarder::OpenDescriptor(desc);
    mSize = surf->GetSize();
    mTexImage = gl()->CreateTextureImage(nsIntSize(mSize.width, mSize.height),
                                         surf->GetContentType(),
                                         LOCAL_GL_CLAMP_TO_EDGE,
                                         mForceSingleTile
                                          ? TextureImage::ForceSingleTile
                                          : TextureImage::NoFlags);
    return true;
  } else {
    YUVImage yuv = aFront.get_YUVImage();

    nsRefPtr<gfxSharedImageSurface> surfY =
      gfxSharedImageSurface::Open(yuv.Ydata());
    nsRefPtr<gfxSharedImageSurface> surfU =
      gfxSharedImageSurface::Open(yuv.Udata());
    nsRefPtr<gfxSharedImageSurface> surfV =
      gfxSharedImageSurface::Open(yuv.Vdata());

    mSize = surfY->GetSize();
    mCbCrSize = surfU->GetSize();

    if (!mYUVTexture[0].IsAllocated()) {
      mYUVTexture[0].Allocate(gl());
      mYUVTexture[1].Allocate(gl());
      mYUVTexture[2].Allocate(gl());
    }

    NS_ASSERTION(mYUVTexture[0].IsAllocated() &&
                 mYUVTexture[1].IsAllocated() &&
                 mYUVTexture[2].IsAllocated(),
                 "Texture allocation failed!");

    gl()->MakeCurrent();
    SetClamping(gl(), mYUVTexture[0].GetTextureID());
    SetClamping(gl(), mYUVTexture[1].GetTextureID());
    SetClamping(gl(), mYUVTexture[2].GetTextureID());
    return true;
  }
  return false;
}
开发者ID:mozilla,项目名称:pjs,代码行数:47,代码来源:ImageLayerOGL.cpp

示例10: 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

示例11: LayerRenderState

LayerRenderState
ShadowImageLayerOGL::GetRenderState()
{
  if (!mImageContainerID) {
    return LayerRenderState();
  }

  // Update the associated compositor ID in case Composer2D succeeds,
  // because we won't enter RenderLayer() if so ...
  ImageContainerParent::SetCompositorIDForImage(
    mImageContainerID, mOGLManager->GetCompositorID());
  // ... but do *not* try to update the local image version.  We need
  // to retain that information in case we fall back on GL, so that we
  // can upload / attach buffers properly.

  SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID);
  if (img && img->type() == SharedImage::TSurfaceDescriptor) {
    return LayerRenderState(&img->get_SurfaceDescriptor());
  }
  return LayerRenderState();
}
开发者ID:Web5design,项目名称:mozilla-central,代码行数:21,代码来源:ImageLayerOGL.cpp

示例12: f

void SharedImageSequence::DeleteSharedImageSequence(const std::string& Name)
{
	// load old info header
	std::stringstream FileNameStream;
	FileNameStream << Name << m_InfFileAttachment;
	int s=0;
	std::ifstream f(FileNameStream.str().c_str());
	if(!f.is_open()) return;

	f >> s;
	SharedImage Dummy;
	for(int i=0; i<s; i++)
	{
		std::stringstream FileNameStream2;
		FileNameStream2 << Name << m_Spacing << i;
		Dummy.DeleteSharedImage(FileNameStream2.str());
		i++;
	}
	f.close();

	std::string name = FileNameStream.str();
	removeFile(name);
}
开发者ID:Yanzqing,项目名称:cob_object_perception,代码行数:23,代码来源:SharedImageSequence.cpp

示例13: 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

示例14: 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

示例15: texBind

void
ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer,
                                 const nsIntPoint& aOffset)
{
  mOGLManager->MakeCurrent();
  if (mImageContainerID) {
    ImageContainerParent::SetCompositorIDForImage(mImageContainerID,
                                                  mOGLManager->GetCompositorID());
    PRUint32 imgVersion = ImageContainerParent::GetSharedImageVersion(mImageContainerID);
    if (imgVersion != mImageVersion) {
      SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID);
      if (img && (img->type() == SharedImage::TYUVImage)) {
        UploadSharedYUVToTexture(img->get_YUVImage());
  
        mImageVersion = imgVersion;
      }
    }
  }


  if (mTexImage) {
    NS_ASSERTION(mTexImage->GetContentType() != gfxASurface::CONTENT_ALPHA,
                 "Image layer has alpha image");

    ShaderProgramOGL *colorProgram =
      mOGLManager->GetProgram(mTexImage->GetShaderProgramType(), GetMaskLayer());

    colorProgram->Activate();
    colorProgram->SetTextureUnit(0);
    colorProgram->SetLayerTransform(GetEffectiveTransform());
    colorProgram->SetLayerOpacity(GetEffectiveOpacity());
    colorProgram->SetRenderOffset(aOffset);
    colorProgram->LoadMask(GetMaskLayer());

    mTexImage->SetFilter(mFilter);
    mTexImage->BeginTileIteration();

    if (gl()->CanUploadNonPowerOfTwo()) {
      do {
        TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
        colorProgram->SetLayerQuadRect(mTexImage->GetTileRect());
        mOGLManager->BindAndDrawQuad(colorProgram);
      } while (mTexImage->NextTile());
    } else {
      do {
        TextureImage::ScopedBindTextureAndApplyFilter texBind(mTexImage, LOCAL_GL_TEXTURE0);
        colorProgram->SetLayerQuadRect(mTexImage->GetTileRect());
        // We can't use BindAndDrawQuad because that always uploads the whole texture from 0.0f -> 1.0f
        // in x and y. We use BindAndDrawQuadWithTextureRect to actually draw a subrect of the texture
        mOGLManager->BindAndDrawQuadWithTextureRect(colorProgram,
                                                    nsIntRect(0, 0, mTexImage->GetTileRect().width,
                                                                    mTexImage->GetTileRect().height),
                                                    mTexImage->GetTileRect().Size());
      } while (mTexImage->NextTile());
    }

  } else {
    gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
    gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[0].GetTextureID());
    gl()->ApplyFilterToBoundTexture(mFilter);
    gl()->fActiveTexture(LOCAL_GL_TEXTURE1);
    gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[1].GetTextureID());
    gl()->ApplyFilterToBoundTexture(mFilter);
    gl()->fActiveTexture(LOCAL_GL_TEXTURE2);
    gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mYUVTexture[2].GetTextureID());
    gl()->ApplyFilterToBoundTexture(mFilter);

    ShaderProgramOGL *yuvProgram = mOGLManager->GetProgram(YCbCrLayerProgramType, GetMaskLayer());

    yuvProgram->Activate();
    yuvProgram->SetLayerQuadRect(nsIntRect(0, 0,
                                           mPictureRect.width,
                                           mPictureRect.height));
    yuvProgram->SetYCbCrTextureUnits(0, 1, 2);
    yuvProgram->SetLayerTransform(GetEffectiveTransform());
    yuvProgram->SetLayerOpacity(GetEffectiveOpacity());
    yuvProgram->SetRenderOffset(aOffset);
    yuvProgram->LoadMask(GetMaskLayer());

    mOGLManager->BindAndDrawQuadWithTextureRect(yuvProgram,
                                                mPictureRect,
                                                nsIntSize(mSize.width, mSize.height));
 }
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:84,代码来源:ImageLayerOGL.cpp


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