本文整理汇总了C++中videoInput::getPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ videoInput::getPixels方法的具体用法?C++ videoInput::getPixels怎么用?C++ videoInput::getPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类videoInput
的用法示例。
在下文中一共展示了videoInput::getPixels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTime
void UpdateTime(float dt)
{
// проверяем наличие кадра
if( VI.isFrameNew(dev) )
{
// копируем содержимое кадра
VI.getPixels(dev, CamImg, true);
}
}
示例2: retrieveFrame
IplImage* CvCaptureCAM_DShow::retrieveFrame()
{
if( !frame || VI.getWidth(index) != frame->width || VI.getHeight(index) != frame->height )
{
cvReleaseImage( &frame );
int w = VI.getWidth(index), h = VI.getHeight(index);
frame = cvCreateImage( cvSize(w,h), 8, 3 );
}
VI.getPixels( index, (uchar*)frame->imageData, false, true );
return frame;
}
示例3: updateTextureFromCamera
HRESULT updateTextureFromCamera( int textureIdx, int deviceId )
{
hr = S_OK;
bool isCreateTexture = false;
if (gTextureSRVs[textureIdx] == NULL)
{
isCreateTexture = true;
}
if (isCreateTexture)
{
while (!gVideoInput.isFrameNew(kDeviceId))
{
::Sleep(30);
}
}
int srcWidth = gVideoInput.getWidth(deviceId);
int srcHeight = gVideoInput.getHeight(deviceId);
BYTE* srcPixels = gVideoInput.getPixels(kDeviceId, true, true);
// texture size is smaller than camera frame size in order to fix the black border issue
int dstWidth = srcWidth - 1;
int dstHeight = srcHeight - 1;
CComPtr<ID3D11Texture2D> tex;
if (isCreateTexture)
{
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_R8G8B8A8_UNORM, dstWidth, dstHeight);
desc.MipLevels = 1;
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
V_RETURN(gDevice->CreateTexture2D( &desc, NULL, &tex ));
V_RETURN(gDevice->CreateShaderResourceView(tex, NULL, &gTextureSRVs[textureIdx]));
}
else
{
gTextureSRVs[textureIdx]->GetResource(reinterpret_cast<ID3D11Resource**>(&tex));
}
struct ColorRGB
{
BYTE r,g,b;
};
struct ColorRGBA
{
ColorRGB rgb;
BYTE a;
};
D3D11_MAPPED_SUBRESOURCE mappedRes;
V_RETURN(gContext->Map(tex, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedRes));
ColorRGB* src = reinterpret_cast<ColorRGB*>(srcPixels);
ColorRGBA* dest = reinterpret_cast<ColorRGBA*>(mappedRes.pData);
UINT pitch = mappedRes.RowPitch / sizeof(ColorRGBA);
for (int y = 0; y < dstHeight; y++)
{
for (int x = 0; x < dstWidth; x++)
{
dest[y * pitch + x].rgb = src[y * srcWidth + srcWidth - x];
dest[y * pitch + x].a = 255;
}
}
gContext->Unmap(tex, 0);
return hr;
}