关于摄像头截图的问题,请高手指教!

safematch 2004-12-16 03:31:45
以前问过这个问题,找到了一些源码,做出了一点东西,现在需要从摄像头拍到的图像里截出一个固定大小的图作为头像,要打在证件上,请问高手,如何在图像上添加一个大小固定的矩形框,鼠标可以拖动,然后可以把框中的图像保存下来。
请指教。
...全文
393 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zm820607 2004-12-29
  • 打赏
  • 举报
回复
mark
safematch 2004-12-17
  • 打赏
  • 举报
回复
还是一头雾水啊
wangxt 2004-12-17
  • 打赏
  • 举报
回复
帮你顶
safematch 2004-12-16
  • 打赏
  • 举报
回复
有没有VB的高手啊,做过的给点提示啊!
safematch 2004-12-16
  • 打赏
  • 举报
回复
谢谢楼上的哥哥,可惜是C#的,还要使劲看
landlordh 2004-12-16
  • 打赏
  • 举报
回复
我有一个相关的例子不知是否可以帮到你:
C#捕捉视频头(源码)

using System;
using System.Runtime.InteropServices;

namespace Wuyin.ShoesManager
{
/// <summary>
/// VedioCapture 的摘要说明。
/// </summary>
public class VedioCapture
{
private int hCaptureM;
private bool isUnLoad = false;
public VedioCapture()
{
}
[DllImport("avicap32.dll")]
private static extern int capCreateCaptureWindow( string strWindowName, int dwStyle, int x, int y ,int width, int height , int hwdParent, int nID );
[DllImport("user32.dll")]
private static extern int SendMessage( int hwnd , int wMsg, int wParam , int lParam );
[DllImport("user32.dll")]
private static extern int SendMessage( int hwnd , int wMsg, int wParam , string lParam );
[DllImport("Kernel32.dll")]
private static extern bool CloseHandle( int hObject );
public bool Initialize( System.Windows.Forms.Control aContainer , int intWidth, int intHeight )
{
hCaptureM = capCreateCaptureWindow( "", 0x40000000 | 0x10000000, 0,0,intWidth,intHeight,aContainer.Handle.ToInt32() ,1 );
if( hCaptureM == 0 ) return false;

int ret = SendMessage( hCaptureM , 1034, 0,0 );
if( ret == 0 )
{
CloseHandle(hCaptureM);
return false;
}
//WM_CAP_SET_PREVIEW
ret = SendMessage( hCaptureM, 1074, 1, 0 );
if( ret == 0 )
{
this.UnLoad();
return false;
}
//WM_CAP_SET_SCALE
ret = SendMessage( hCaptureM, 1077, 1, 0 );
if( ret == 0 )
{
this.UnLoad();
return false;
}
//WM_CAP_SET_PREVIEWRATE
ret = SendMessage( hCaptureM, 1076, 66, 0 );
if( ret == 0 )
{
this.UnLoad();
return false;
}
return true;
}

public void SingleFrameBegin()
{
//
int ret = SendMessage( hCaptureM, 1094 , 0, 0 );
}
public void SingleFrameEnd()
{
//
int ret = SendMessage( hCaptureM, 1095 , 0, 0 );
}

public void SingleFrameMode()
{
//WM_CAP_GRAB_FRAME
int ret = SendMessage( hCaptureM, 1084 , 0, 0 );
//WM_CAP_SET_PREVIEW
//int ret = SendMessage( hCaptureM, 1074 , 0, 0 );
//WM_CAP_SINGLE_FRAME
//ret = SendMessage( hCaptureM, 1096 , 0, 0 );
}
public void PreviewMode()
{
int ret = SendMessage( hCaptureM, 1074 , 1, 0 );
}

public void UnLoad()
{
int ret = SendMessage( hCaptureM, 1035, 0, 0 );
CloseHandle( this.hCaptureM );
isUnLoad = true;
}

public void CopyToClipBorad()
{
int ret = SendMessage( hCaptureM, 1054, 0, 0 );
}

public void ShowFormatDialog()
{
int ret = SendMessage( hCaptureM, 1065, 0, 0 );
}
public void SaveToDIB( string fileName )
{
int ret = SendMessage( hCaptureM, 1049, 0, fileName );
}

public void ShowDisplayDialog()
{
int ret = SendMessage( hCaptureM, 1067, 0, 0 );
}
public System.Drawing.Image getCaptureImage()
{
System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
System.Drawing.Image retImage = null;
if( iData != null )
{
if( iData.GetDataPresent( System.Windows.Forms.DataFormats.Bitmap ) )
{
retImage = (System.Drawing.Image)iData.GetData( System.Windows.Forms.DataFormats.Bitmap );
}
else if( iData.GetDataPresent( System.Windows.Forms.DataFormats.Dib ) )
{
retImage = (System.Drawing.Image)iData.GetData( System.Windows.Forms.DataFormats.Dib );
}
}
return retImage;
}

~VedioCapture()
{
if( !isUnLoad )
{
this.UnLoad();
}
}
}
}
safematch 2004-12-16
  • 打赏
  • 举报
回复
大概和楼上的哥哥说得差不多,就是把截到的图片放在一个picturebox里边,就是不知道那个框是应该由avicap32.dll提供呢,还是可以自己写出来,比如,在picturebox里画好一个框,把在框内的图另外保存一个文件,就是不知道具体怎么做,请高手给点提示!
liuchengit 2004-12-16
  • 打赏
  • 举报
回复
显示图片的载体应该是个picturebox这样的控件吧,在鼠标按住拖动的过程中,首先应该是按下鼠标,这时记下坐标,当鼠标拖动完成抬起时也要记录一个坐标,这样就有一个选择区域了,不过这个不食最佳的解决办法,,我看过这样的一个例子,,当数码相机或是其他设备取到像后有个默认的选择框,,可以将这个选择框拖动图片的某个位置,然后单击这样就取到像了,,不过这样做会很麻烦了,,不知道avicap32.dll是否提供这个功能,,应该有吧?
youwanna 2004-12-16
  • 打赏
  • 举报
回复
偶帮你顶一下,呵呵
我想要用GDI+吧,自己没有用过
safematch 2004-12-16
  • 打赏
  • 举报
回复
我调用了avicap32.dll和user32,请高手帮忙

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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