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


C++ INuiFrameTexture类代码示例

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


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

示例1: Mat

//Put the kinect imageframe data onto a Mat
Mat* KOCVStream::kFrameToMat(NUI_IMAGE_FRAME* imageFrame){

	Mat* frame = new Mat(height, width, CV_8U);
	
	NUI_LOCKED_RECT LockedRect;

	//Lock the imageFrame such that kinnect cannot write on it
	INuiFrameTexture* texture = imageFrame->pFrameTexture;
	texture->LockRect(0, &LockedRect, NULL, 0);

	//Get the kinect depth data
	BYTE* imageData;
	
	kinect->getDepthData(&LockedRect);
	imageData = kinect->dataPix;
	
	//If the data is not empty convert it to Mat
	if (LockedRect.Pitch != 0){
		/* //Do not do new above!
		   frame=new Mat(height, width, CV_8U, imageData);	
		*/
		Mat tempMat(height, width, CV_8U, imageData);
		tempMat.copyTo(*frame);
	}
	else{
		return new Mat();
	}
	
	//Release the frame
	texture->UnlockRect(0);

	return frame;
};
开发者ID:vladotrocol,项目名称:bubble_source,代码行数:34,代码来源:KOCVStream.cpp

示例2: WaitForSingleObject

void KinectCam::Nui_GetCamFrame(BYTE *frameBuffer, int frameSize)
{
    const NUI_IMAGE_FRAME *pImageFrame = NULL;

	WaitForSingleObject(m_hNextVideoFrameEvent, INFINITE);

    HRESULT hr = NuiImageStreamGetNextFrame(
        m_pVideoStreamHandle,
        0,
        &pImageFrame );
    if( FAILED( hr ) )
    {
        return;
    }

    INuiFrameTexture *pTexture = pImageFrame->pFrameTexture;
    NUI_LOCKED_RECT LockedRect;
    pTexture->LockRect( 0, &LockedRect, NULL, 0 );
    if( LockedRect.Pitch != 0 )
    {
        BYTE * pBuffer = (BYTE*) LockedRect.pBits;
		memcpy(frameBuffer, pBuffer, frameSize);
    }

    NuiImageStreamReleaseFrame( m_pVideoStreamHandle, pImageFrame );
}
开发者ID:Craigimus,项目名称:KinectCam,代码行数:26,代码来源:KinectCam.cpp

示例3: createRGBImage

int createRGBImage(HANDLE h, IplImage* Color)
{
    const NUI_IMAGE_FRAME *pImageFrame = NULL;

    HRESULT hr = NuiImageStreamGetNextFrame(h, 1000, &pImageFrame);

    if(FAILED(hr))
    {
        cout << "Create RGB Image Failed\n";
        return -1;
    }

    INuiFrameTexture *pTexture = pImageFrame->pFrameTexture;
    NUI_LOCKED_RECT LockedRect;
    pTexture->LockRect(0, &LockedRect, NULL, 0);

    if(LockedRect.Pitch != 0)
    {
        BYTE * pBuffer = (BYTE*)LockedRect.pBits;
        cvSetData(Color, pBuffer, LockedRect.Pitch);
        cvShowImage("Color Image", Color);
    }

    NuiImageStreamReleaseFrame(h, pImageFrame);

    return 0;
}
开发者ID:minimon,项目名称:kinectHR,代码行数:27,代码来源:main.cpp

示例4: UpdateColor

void SimpleKinect::UpdateColor()
{
	HRESULT hr;
    NUI_IMAGE_FRAME imageFrame;
	hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pColorStreamHandle, 0, &imageFrame);
    if (FAILED(hr))
    {
        return;
    }

	INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
    NUI_LOCKED_RECT LockedRect;
	// Lock the frame data so the Kinect knows not to modify it while we're reading it
    pTexture->LockRect(0, &LockedRect, NULL, 0);

	// make sure we're receiving real data
	if (LockedRect.Pitch == 0) 
	{
		return;
	}

	// copy current to old
	memcpy(m_pPrevRGB, m_pCurrentRGB, LockedRect.size);
	    
	// copy in data to current
	memcpy(m_pCurrentRGB, LockedRect.pBits, LockedRect.size);

    // We're done with the texture so unlock it
    pTexture->UnlockRect(0);

    // Release the frame
    m_pNuiSensor->NuiImageStreamReleaseFrame(m_pColorStreamHandle, &imageFrame);

}
开发者ID:julenka,项目名称:simplekinectcpp,代码行数:34,代码来源:SimpleKinect.cpp

示例5: NuiImageStreamGetNextFrame

void KinectSensor::GotDepthAlert( )
{
    const NUI_IMAGE_FRAME* pImageFrame = NULL;

    HRESULT hr = NuiImageStreamGetNextFrame(m_pDepthStreamHandle, 0, &pImageFrame);

    if (FAILED(hr))
    {
        return;
    }

    INuiFrameTexture* pTexture = pImageFrame->pFrameTexture;
    NUI_LOCKED_RECT LockedRect;
    pTexture->LockRect(0, &LockedRect, NULL, 0);
    if (LockedRect.Pitch)
    {   // Copy depth frame to face tracking
        memcpy(m_DepthBuffer->GetBuffer(), PBYTE(LockedRect.pBits), min(m_DepthBuffer->GetBufferSize(), UINT(pTexture->BufferLen())));
    }
    else
    {
        OutputDebugString( L"Buffer length of received depth texture is bogus\r\n" );
    }

    hr = NuiImageStreamReleaseFrame(m_pDepthStreamHandle, pImageFrame);
}
开发者ID:jaehwan,项目名称:Hair,代码行数:25,代码来源:KinectSensor.cpp

示例6: gotColorAlert

//Handles color data
bool Kinect::gotColorAlert()
{
	NUI_IMAGE_FRAME frame;
	bool processedFrame = true;
	//get the next frame from the Kinect
	HRESULT hr = globalNui->NuiImageStreamGetNextFrame( videoStreamHandle, 0, &frame);

	if (FAILED( hr ) )
	{
		return false;
	}
	//get the data we need: frame now also contains information about the kinect it came from, etc. We do not need that.
	INuiFrameTexture * texture = frame.pFrameTexture;
	NUI_LOCKED_RECT lockedRect;
	//lock the data we are going to use, so that other threads cant change it while we are using it.
	texture->LockRect( 0, &lockedRect, NULL, 0);
	if( lockedRect.Pitch != 0)
	{
		//draw it to the screen.
		//mutex waiting, 5 ms timeout
		bitmap->CopyFromMemory(NULL, static_cast<BYTE *>(lockedRect.pBits), 640 * 4);
		DWORD result = WaitForSingleObject(mutex,5);
		if (result == WAIT_OBJECT_0){
			__try {
				faceTracker->setColorVars(lockedRect, texture);
			}
			__finally {
				ReleaseMutex(mutex);
			}
		}
开发者ID:ProjectPrague,项目名称:KinectMain,代码行数:31,代码来源:kinect.cpp

示例7:

UINT16 * Kinect1::getDepthBuffer()
{
	int result;

	// Grab an image frame
	NUI_IMAGE_FRAME imageFrame;
	result = sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame);
	// Make sure the frame is not empty
	if (result >= 0)
	{
		// Get frame texture
		NUI_LOCKED_RECT lockedRect;
		INuiFrameTexture * texture = imageFrame.pFrameTexture;
		texture->LockRect(0, &lockedRect, NULL, 0);

		UINT16 * bufferIndex = depthBuffer;
		UINT16 * frameIndex = (UINT16 *) lockedRect.pBits;
		UINT16 * end = frameIndex + (depthWidth * depthHeight);

		// Copy data to buffer
		while (frameIndex < end)
		{
			// 4 byte BGRA to 1 int ARGB
			*bufferIndex = NuiDepthPixelToDepth(*frameIndex);
			bufferIndex++;
			frameIndex++;
		}

		// Release
		texture->LockRect(0, &lockedRect, NULL, 0);
		sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame);
	}

	return depthBuffer;
}
开发者ID:intel-cornellcup,项目名称:r2kart-demo,代码行数:35,代码来源:Kinect1.cpp

示例8: NuiImageStreamGetNextFrame

int Read_Kinect::drawColor(HANDLE h)
{
	const NUI_IMAGE_FRAME * pImageFrame = NULL;
	HRESULT hr = NuiImageStreamGetNextFrame(h, 0, &pImageFrame);
	if (FAILED(hr)) 
	{
		cout << "Get Image Frame Failed" << endl;
		return -1;
	}
	INuiFrameTexture * pTexture = pImageFrame->pFrameTexture;
	NUI_LOCKED_RECT LockedRect;
	pTexture->LockRect(0, &LockedRect, NULL, 0);
	if (LockedRect.Pitch != 0)
	{
		BYTE * pBuffer = (BYTE*) LockedRect.pBits;

		_color = Mat(COLOR_HIGHT,COLOR_WIDTH,CV_8UC4,pBuffer);
		for (int i=0; i<COLOR_HIGHT; i++)
			for(int j=0; j<COLOR_WIDTH; j++)
		{
			_bottom_left_img.at<Vec3b>(i,j).val[0] = _color.at<Vec4b>(i,j).val[0];
			_bottom_left_img.at<Vec3b>(i,j).val[1] = _color.at<Vec4b>(i,j).val[1];
			_bottom_left_img.at<Vec3b>(i,j).val[2] = _color.at<Vec4b>(i,j).val[2];

		}
		
//		imshow("color image", _color);
	}
	NuiImageStreamReleaseFrame(h, pImageFrame);
	return 0;
}
开发者ID:SaligNL,项目名称:timeseries_classification,代码行数:31,代码来源:read_from_kinect.cpp

示例9: updateImageFrame

void updateImageFrame( NUI_IMAGE_FRAME& imageFrame, bool isDepthFrame )
{
    INuiFrameTexture* nuiTexture = imageFrame.pFrameTexture;
    NUI_LOCKED_RECT lockedRect;
    nuiTexture->LockRect( 0, &lockedRect, NULL, 0 );
    if ( lockedRect.Pitch!=NULL )
    {
        const BYTE* buffer = (const BYTE*)lockedRect.pBits;
        for ( int i=0; i<480; ++i )
        {
            const BYTE* line = buffer + i * lockedRect.Pitch;
            const USHORT* bufferWord = (const USHORT*)line;
            for ( int j=0; j<640; ++j )
            {
                if ( !isDepthFrame )
                {
                    unsigned char* ptr = colorTexture->bits + 3 * (i * 640 + j);
                    *(ptr + 0) = line[4 * j + 2];
                    *(ptr + 1) = line[4 * j + 1];
                    *(ptr + 2) = line[4 * j + 0];
                }
                else
                    setPlayerColorPixel( bufferWord[j], j, i, 255 );
            }
        }
        
        TextureObject* tobj = (isDepthFrame ? playerColorTexture : colorTexture);
        glBindTexture( GL_TEXTURE_2D, tobj->id );
        glTexImage2D( GL_TEXTURE_2D, 0, tobj->internalFormat, tobj->width, tobj->height,
                      0, tobj->imageFormat, GL_UNSIGNED_BYTE, tobj->bits );
    }
    nuiTexture->UnlockRect( 0 );
}
开发者ID:Corcova,项目名称:augmented-reality-with-microsoft-kinect,代码行数:33,代码来源:ch3_03.cpp

示例10: Nui_GotColorAlert

bool Nui_GotColorAlert( )
{
	NUI_IMAGE_FRAME imageFrame;
	bool processedFrame = true;

	HRESULT hr = m_pNuiSensor->NuiImageStreamGetNextFrame( m_pVideoStreamHandle, 0, &imageFrame );

	if ( FAILED( hr ) )
	{
		return false;
	}

	INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
	NUI_LOCKED_RECT LockedRect;
	pTexture->LockRect( 0, &LockedRect, NULL, 0 );
	if ( LockedRect.Pitch != 0 )
	{
		memcpy(g_ColorsData, LockedRect.pBits, LockedRect.size);
	}
	else
	{
		//OutputDebugString( L"Buffer length of received texture is bogus\r\n" );
		processedFrame = false;
	}

	pTexture->UnlockRect( 0 );

	m_pNuiSensor->NuiImageStreamReleaseFrame( m_pVideoStreamHandle, &imageFrame );

	return processedFrame;
}
开发者ID:iktu,项目名称:3dreconstruction,代码行数:31,代码来源:NuiImpl.cpp

示例11: getRgbData

void getRgbData(GLubyte* dest) {
	float* fdest = (float*) dest;
	long* depth2rgb = (long*) depthToRgbMap;
	NUI_IMAGE_FRAME imageFrame;
    NUI_LOCKED_RECT LockedRect;
    if (sensor->NuiImageStreamGetNextFrame(rgbStream, 0, &imageFrame) < 0) return;
    INuiFrameTexture* texture = imageFrame.pFrameTexture;
    texture->LockRect(0, &LockedRect, NULL, 0);
    if (LockedRect.Pitch != 0) {
        const BYTE* start = (const BYTE*) LockedRect.pBits;
        for (int j = 0; j < height; ++j) {
			for (int i = 0; i < width; ++i) {
				// Determine rgb color for each depth pixel
				long x = *depth2rgb++;
				long y = *depth2rgb++;
				// If out of bounds, then don't color it at all
				if (x < 0 || y < 0 || x > width || y > height) {
					for (int n = 0; n < 3; ++n) *(fdest++) = 0.0f;
				}
				else {
					const BYTE* curr = start + (x + width*y)*4;
					for (int n = 0; n < 3; ++n) *(fdest++) = curr[2-n]/255.0f;
				}

			}
		}
    }
    texture->UnlockRect(0);
    sensor->NuiImageStreamReleaseFrame(rgbStream, &imageFrame);
}
开发者ID:VCunhaJ,项目名称:softkinetic_interactive_Gesture_Camera,代码行数:30,代码来源:main.cpp

示例12: Nui_GotRgbAlert

void KinectDevice::Nui_GotRgbAlert()
{
    NUI_IMAGE_FRAME imageFrame;

    HRESULT hr = m_pNuiSensor->NuiImageStreamGetNextFrame(
                     m_pVideoStreamHandle,
                     0,
                     &imageFrame );
    if( FAILED( hr ) )
    {
        return;
    }

    INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
    NUI_LOCKED_RECT LockedRect;
    pTexture->LockRect( 0, &LockedRect, NULL, 0 );
    if( LockedRect.Pitch != 0 )
    {
        // TODO:
        //cvSetData(iplColor, LockedRect.pBits, iplColor->widthStep);
        Mat ref;//(iplColor);
        if (_delegate)
            _delegate->onRgbData(ref);
        isNewFrames[FRAME_COLOR_U8C3] = true;
    }
    else
    {
        OutputDebugString( L"Buffer length of received texture is bogus\r\n" );
    }

    m_pNuiSensor->NuiImageStreamReleaseFrame( m_pVideoStreamHandle, &imageFrame );
}
开发者ID:vnm-interactive,项目名称:_common,代码行数:32,代码来源:KinectDevice.cpp

示例13: getDepthData

void getDepthData(GLubyte* dest) {
	float* fdest = (float*) dest;
	long* depth2rgb = (long*) depthToRgbMap;
    NUI_IMAGE_FRAME imageFrame;
    NUI_LOCKED_RECT LockedRect;
    if (sensor->NuiImageStreamGetNextFrame(depthStream, 0, &imageFrame) < 0) return;
    INuiFrameTexture* texture = imageFrame.pFrameTexture;
    texture->LockRect(0, &LockedRect, NULL, 0);
    if (LockedRect.Pitch != 0) {
        const USHORT* curr = (const USHORT*) LockedRect.pBits;
        for (int j = 0; j < height; ++j) {
			for (int i = 0; i < width; ++i) {
				// Get depth of pixel in millimeters
				USHORT depth = NuiDepthPixelToDepth(*curr++);
				// Store coordinates of the point corresponding to this pixel
				Vector4 pos = NuiTransformDepthImageToSkeleton(i, j, depth<<3, NUI_IMAGE_RESOLUTION_640x480);
				*fdest++ = pos.x/pos.w;
				*fdest++ = pos.y/pos.w;
				*fdest++ = pos.z/pos.w;
				// Store the index into the color array corresponding to this pixel
				NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution(
					NUI_IMAGE_RESOLUTION_640x480, NUI_IMAGE_RESOLUTION_640x480, NULL,
					i, j, depth<<3, depth2rgb, depth2rgb+1);
				depth2rgb += 2;
			}
		}
    }
    texture->UnlockRect(0);
    sensor->NuiImageStreamReleaseFrame(depthStream, &imageFrame);
}
开发者ID:VCunhaJ,项目名称:softkinetic_interactive_Gesture_Camera,代码行数:30,代码来源:main.cpp

示例14: ProcessColor

/// <summary>
/// Handle new color data
/// </summary>
/// <returns>S_OK for success or error code</returns>
HRESULT KinectEasyGrabber::ProcessColor()
{
    HRESULT hr = S_OK;
    NUI_IMAGE_FRAME imageFrame;

    // Attempt to get the depth frame
    hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pColorStreamHandle, 0, &imageFrame);
    if (FAILED(hr))
    {
        return hr;
    }

    m_colorTimeStamp = imageFrame.liTimeStamp;

    INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
    NUI_LOCKED_RECT LockedRect;

    // Lock the frame data so the Kinect knows not to modify it while we're reading it
    pTexture->LockRect(0, &LockedRect, NULL, 0);

    // Make sure we've received valid data
    if (LockedRect.Pitch != 0)
    {
        memcpy(m_colorRGBX, LockedRect.pBits, LockedRect.size);
    }

    // We're done with the texture so unlock it
    pTexture->UnlockRect(0);

    // Release the frame
    m_pNuiSensor->NuiImageStreamReleaseFrame(m_pColorStreamHandle, &imageFrame);

    return hr;
}
开发者ID:cmorato,项目名称:kinect-easy-grabber,代码行数:38,代码来源:KinectEasyGrabber.cpp

示例15: ProcessColor

/// <summary>
/// Handle new color data
/// </summary>
/// <returns>indicates success or failure</returns>
void CDataCollection::ProcessColor()
{
    HRESULT hr;
    NUI_IMAGE_FRAME imageFrame;
	//DEBUG("Process color!\n");
    // Attempt to get the color frame
    hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pColorStreamHandle, 0, &imageFrame);
    if (FAILED(hr))
    {
        return;
    }
	

    INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
    NUI_LOCKED_RECT LockedRect;

    // Lock the frame data so the Kinect knows not to modify it while we're reading it
    pTexture->LockRect(0, &LockedRect, NULL, 0);

    // Make sure we've received valid data
    if (LockedRect.Pitch != 0)
    {
        // Draw the data with Direct2D
        m_pDrawColor->Draw(static_cast<BYTE *>(LockedRect.pBits), LockedRect.size);

      
        
    }

    // We're done with the texture so unlock it
    pTexture->UnlockRect(0);

    // Release the frame
    m_pNuiSensor->NuiImageStreamReleaseFrame(m_pColorStreamHandle, &imageFrame);
}
开发者ID:eaglesky,项目名称:ARLK,代码行数:39,代码来源:DataCollection.cpp


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