熟悉VFW的进来,如何控制视频预览的大小(在线等)

huaboy2004 2004-09-28 11:14:40
利用网上的代码做了一个视频采集的小程序,现在需要实现如下功能

已有如下函数:
/*******************************************************************************
Function : EnablePreviewVideo
Arguments : Parent (input) - Parent window that will display video.
x (input) - X Location in parent where video will be shown.
y (input) - Y location in parent where video will be shown.
Width (input) - Width of preview window.
Height (input) - Height of preview window.
PreviewRate (input) - Rate of preview in FPS.
Return : TRUE Success, FALSE Failed.
Description: Enables preview video mode.
*******************************************************************************/
BOOL CVFWImageProcessor::EnablePreviewVideo(HWND Parent, INT x, INT y, INT Width, INT Height, INT PreviewRate)
{
// Reset any error conditions.
GetPreviousError(NULL,NULL,TRUE);

SetParent(m_hWndVideo,Parent);
SetWindowLong(m_hWndVideo,GWL_STYLE,WS_CHILD);

SetWindowPos(m_hWndVideo,NULL,x,y,
Width,
Height,
SWP_NOZORDER);
ShowWindow(m_hWndVideo,SW_SHOW);
capPreviewRate(m_hWndVideo, PreviewRate);

return capPreview(m_hWndVideo,TRUE);
}

现在已经通过获取预览窗口CRect rectVideo的大小,但是视频显示的还是与视频格式设置大小一致,只能在窗口内显示视频左上角的一部分,没有实现视频的缩放,所以显示不全。我现在就想缩放视频预览显示到设定区域,但实际的视频大小不要改变,因为抓图还是要实际大小的。

哪位大侠熟悉视频窗口大小控制的帮忙啊,老大已经催着完工了,着急啊!
...全文
296 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
huaboy2004 2004-10-06
  • 打赏
  • 举报
回复
终于解决了,capPreviewScale就加这么个伸缩函数就OK了,费了我那么大劲还是不熟悉的原因啊。

谢谢诸位帮忙,可能雅克的方法也行,不过我理解不了,只要找简单的来实现了,嘿嘿
huaboy408 2004-10-05
  • 打赏
  • 举报
回复
自动缩放视频到视频窗口大小:
在你的capPreviewRate(...)之后加上capPreviewScale(hwnd,TRUE)试试

附MSDN:
BOOL capPreviewScale( hwnd, f );

Parameters
hwnd
Handle of a capture window.
f
Preview scaling flag. Specify TRUE for this parameter to stretch preview frames to the size of the capture window or FALSE to display them at their natural size.
Return Values
Returns TRUE if successful or FALSE otherwise.

Remarks
Scaling preview images controls the immediate presentation of captured frames within the capture window. It has no effect on the size of the frames saved to file.

Scaling has no effect when using overlay to display video in the frame buffer.


另:
抓图时候设置大小:
HWND m_capwnd=capCreateCaptureWindow(.......);
BITMAPINFO m_bmpinfo;
capGetVideoFormat(m_capwnd,&m_bmpinfo,sizeof(m_bmpinfo));

m_bmpinfo.bmiHeader.biWidth和m_bmpinfo.bmiHeader.biHeight就是你想要的视频宽度和高度

设置大小:
m_bmpinfo.bmiHeader.biWidth=176;//320
m_bmpinfo.bmiHeader.biHeight=144;//240
BOOL ret=capSetVideoFormat(m_capwnd,&m_bmpinfo,sizeof(m_bmpinfo));

rainsly 2004-10-04
  • 打赏
  • 举报
回复
up
nwpulipeng 2004-10-03
  • 打赏
  • 举报
回复
帮顶混分
fastxyf 2004-10-03
  • 打赏
  • 举报
回复
如果不是摄像头支持的大小(176*144,320*240等),一般都是通过自已转换成小的再显示。
简单的转换可以用StretchBlt,不过很占CPU。
huaboy2004 2004-09-29
  • 打赏
  • 举报
回复
楼上提供的跟我上面所列的函数好像没什么区别吧,问题视频大小根本不变,改变的只是显示区域的大小
DentistryDoctor 2004-09-28
  • 打赏
  • 举报
回复
capSetCallbackOnVideoStream
huaboy2004 2004-09-28
  • 打赏
  • 举报
回复
我仅仅想缩放一下动态视频窗口,采集后的数据如何再显示为动态视频?还有Overlay有没有例子啊
DentistryDoctor 2004-09-28
  • 打赏
  • 举报
回复
将采集出来的数据,送给自己的显示程序。要缩放的话最好用Overlay.
DentistryDoctor 2004-09-28
  • 打赏
  • 举报
回复
这个,你只有自己负责显示了。
huaboy2004 2004-09-28
  • 打赏
  • 举报
回复
怎么显示不出来,自己UP
chwk 2004-09-28
  • 打赏
  • 举报
回复
HRESULT SetWindowPosition(
long Left,
long Top,
long Width,
long Height
);

Parameters

Left

[in] Specifies the x-coordinate, in pixels.

Top

[in] Specifies the y-coordinate, in pixels.

Width

[in] Specifies the width, in pixels.

Height

[in] Specifies the height, in pixels.

chwk 2004-09-28
  • 打赏
  • 举报
回复
DirectX 9.0中找
IVideoWindow的
SetWindowPosition 方法

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧