小编Rob*_*nes的帖子

C++ Direct3D多屏捕获

您好Direct3D专家,

我目前正在使用Direct3D开发一个应用程序,以捕获我的两个监视器桌面(当然用作扩展桌面).以下代码运行良好,但我只能捕获主显示而不是扩展桌面(只捕获一个屏幕两次)

如何针对双屏幕捕获调整此解决方案?

首先,我初始化Direct3D:

D3DDISPLAYMODE          d3dDisplayMode;
D3DPRESENT_PARAMETERS   d3dPresentationParameters; //Presentation parameters (backbufferwidth, height...)

if( (pSinfo->g_pD3D=Direct3DCreate9(D3D_SDK_VERSION)) == NULL )
    return FALSE;

if( pSinfo->g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3dDisplayMode) ==  D3DERR_INVALIDCALL )
    return FALSE;

ZeroMemory(&d3dPresentationParameters,sizeof(D3DPRESENT_PARAMETERS));   
d3dPresentationParameters.Windowed = TRUE;
d3dPresentationParameters.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
d3dPresentationParameters.BackBufferFormat = d3dDisplayMode.Format;
d3dPresentationParameters.BackBufferHeight = gScreenRect.bottom = d3dDisplayMode.Height;
d3dPresentationParameters.BackBufferWidth = gScreenRect.right = d3dDisplayMode.Width;
d3dPresentationParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dPresentationParameters.SwapEffect= D3DSWAPEFFECT_DISCARD;
d3dPresentationParameters.hDeviceWindow = hWnd;
d3dPresentationParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
d3dPresentationParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;

pSinfo->uiWidth = d3dDisplayMode.Width;
pSinfo->uiHeight = d3dDisplayMode.Height;

if( pSinfo->g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING ,&d3dPresentationParameters,&pSinfo->g_pd3dDevice) != D3D_OK )
    return FALSE;
Run Code Online (Sandbox Code Playgroud)

然后,执行连续屏幕截图并在pData中保存图像数据的循环:

while(1)
{
    pSinfo->g_pd3dDevice->GetRenderTarget(0, &pSinfo->pRenderSurface); …
Run Code Online (Sandbox Code Playgroud)

c++ multiple-monitors direct3d capture

5
推荐指数
1
解决办法
1524
查看次数

Qt:Qt5 Windows中BitBlt的替代品

我目前正在从Qt3到Qt5 移植一个开源解决方案(Albatross ATM解决方案http://www.albatross.aero/).信天翁是一个空中交通观众,需要非常好的表现.我可以管理各种问题,但不能显示部分.

显示架构依赖于一个bitblt命令,该命令首先将一个像素图复制到另一个像素图中,最后将像素图复制到屏幕上.

这是Qt3显示代码(工作和性能):

void CAsdView::paintEvent ( QPaintEvent * Event)
{
    QRect   rcBounds=Event->rect();

    QPainter tmp;

    for (int lay=0;lay<(int)m_RectTable.size();lay++) //For each drawing layer (there are 3) 
    {

        if (!m_RectTable[lay].isEmpty())
        {
            if (lay!=0)
                bitBlt(m_BitmapTable[lay],m_RectTable[lay].left(),m_RectTable[lay].top(),m_BitmapTable[lay-1],m_RectTable[lay].left(),m_RectTable[lay].top(),m_RectTable[lay].width(),m_RectTable[lay].height(),CopyROP); //m_BitmapTable is a QVector< QPixmap* >, m_RectTable is a QVector<QRect>

            tmp.begin(m_BitmapTable[lay]);

            if (lay==0)
                tmp.fillRect(m_RectTable[lay], *m_pBrush);

            OnDraw(&tmp,lay);
            tmp.end();
            m_RectTable[lay].setRect(0,0,-1,-1);
        }
    }
    bitBlt(this, rcBounds.left(), rcBounds.top(),m_BitmapTable[m_LayerNb-1],rcBounds.left(), rcBounds.top(),rcBounds.width(), rcBounds.height(), CopyROP);  
}
Run Code Online (Sandbox Code Playgroud)

我试过替换bitblt,drawPixmap但性能非常差,因为我必须经常显示屏幕.

这是新的Qt5代码:

void CAsdView::paintEvent ( QPaintEvent * Event)
{
    QRect   rcBounds=Event->rect(); …
Run Code Online (Sandbox Code Playgroud)

c++ qt porting bitblt qt5

5
推荐指数
1
解决办法
1727
查看次数

OCR:两帧之间的差异

我试图找到一个简单的解决方案来实现OPenCVOCR算法.我是图像处理的新手!我正在播放使用RLE算法使用特定编解码器解码的视频.

我想要做的是,对于每个解码帧,我想将它与前一帧进行比较,并存储两帧之间已经改变的像素.

大多数现有的解决方案给出了两个帧之间的差异,但我想保留已更改的新像素并将其存储在表中,然后能够分析已更改的每组像素而不是分析整个图像每一次.

我计划使用" 斑点检测 "算法,在我能够实现它之前,我已经卡住了.

今天,我正在尝试这个:

char *prevFrame;
char *curFrame;
QVector DiffPixel<LONG>;

//for each frame
DiffPixel.push_back(curFrame-prevFrame);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我真的想拥有"仅改变像素结果"的解决方案.如果我走错路,有人可以给我一些提示或纠正我吗?

编辑:

新问题,如果有多个像素区域变化怎么办?是否可以在每个更改像素的区域中拥有一个表,或者它只是一个唯一的表?举个例子:

多个区域像素

结果最好的是有2个垫子矩阵.第一个矩阵具有第一个橙色正方形,第二个矩阵具有第二个橙色正方形.这样,如果我们将结果存储在一个矩阵中,只有分辨率与全帧几乎相同,它就避免了必须"扫描"几乎整个帧.

这里的主要目标是最小化要分析以查找文本的区域(也称为分辨率).

c++ opencv blob image-processing

5
推荐指数
1
解决办法
564
查看次数

FFmpeg:编码PCM 16音频数据分配错误

我目前正在尝试在avi容器中使用一些视频对一些原始音频数据进行编码。

所使用的视频编解码器是mpeg4,我想将PCM_16LE用于音频编解码器,但我面临有关音频样本的AVCodec-> frame_size参数的问题。

完成所有正确的分配后,我尝试分配音频帧,对于AV_CODEC_ID_PCM_S16LE编解码器,我没有获得样本缓冲区大小所需的编解码器frame_size。因此,样本缓冲区的大小很大,我根本无法分配这么多的内存。有人知道如何绕过此问题以及如何手动计算frame_size吗?

    frame = av_frame_alloc();
    if(!frame)
    {
        return NULL;
    }

    //Problem is right here with the frame_size
    frame->nb_samples = m_pAudioCodecContext->frame_size;
    frame->format = m_pAudioStream->codec->sample_fmt;
    frame->channel_layout = m_pAudioStream->codec->channel_layout;

    //The codec gives us the frame size, in samples, so we can calculate the size of the samples buffer in bytes
    //This returns a huge value due to a null frame_size
    m_audioSampleBufferSize = av_samples_get_buffer_size(NULL,
                                                         m_pAudioCodecContext->channels,
                                                         m_pAudioCodecContext->frame_size,
                                                         m_pAudioCodecContext->sample_fmt,
                                                         0);
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助,

罗伯特

c++ audio ffmpeg pcm

1
推荐指数
1
解决办法
850
查看次数