导航:首页 > 源码编译 > 汇编摄像头源码

汇编摄像头源码

发布时间:2022-08-06 17:34:10

❶ 求一个控制摄像头小程序的源码,要求VC下编译运行

VC-摄像头控制SDK源码
#include <windows.h>
#include <stdio.h>
#include <vfw.h>
#pragma comment(lib,"vfw32.lib")

HWND ghWndCap ; //捕获窗的句柄
CAPDRIVERCAPS gCapDriverCaps ; //视频驱动器的能力
CAPSTATUS gCapStatus ; //捕获窗的状态
char szCaptureFile[] = "MYCAP.AVI";
char gachBuffer[20];

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

LRESULT CALLBACK StatusCallbackProc(HWND hWnd,int nID,LPSTR lpStatusText)
{
if(!ghWndCap)return FALSE;//获得捕获窗的状态
capGetStatus(ghWndCap,&gCapStatus,sizeof(CAPSTATUS));//更新捕获窗的大小
SetWindowPos(ghWndCap,NULL,0,0,gCapStatus.uiImageWidth,gCapStatus.uiImageHeight,SWP_NOZORDER|SWP_NOMOVE);
if(nID==0){//清除旧的状态信息
SetWindowText(ghWndCap,(LPSTR)"hello");
return (LRESULT)TRUE;
}//显示状态ID和状态文本
wsprintf(gachBuffer,"Status# %d: %s",nID,lpStatusText);
SetWindowText(ghWndCap,(LPSTR)gachBuffer);
return (LRESULT)TRUE;
}
LRESULT CALLBACK ErrorCallbackProc(HWND hWnd,int nErrID,LPSTR lpErrorText)
{
if(!ghWndCap)return FALSE;
if(nErrID==0)return TRUE;//清除旧的错误
wsprintf(gachBuffer,"Error# %d",nErrID);//显示错误标识和文本
MessageBox(hWnd, lpErrorText, gachBuffer,MB_OK | MB_ICONEXCLAMATION);
return (LRESULT) TRUE;
}

LRESULT CALLBACK FrameCallbackProc(HWND hWnd,LPVIDEOHDR lpVHdr)
{
FILE *fp;
fp=fopen("caram.dat","w");
if(!ghWndCap)return FALSE;//假设fp为一打开的.dat文件指针
fwrite(lpVHdr->lpData,1,lpVHdr->dwBufferLength,fp);
return (LRESULT)TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires WindowsNT!"),szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,TEXT("The Hello Program"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
{
ghWndCap=capCreateCaptureWindow((LPSTR)"Capture Window",WS_CHILD|WS_VISIBLE,0,0,300,240,(HWND)hwnd,(int)0);
capSetCallbackOnError(ghWndCap,(FARPROC)ErrorCallbackProc);
capSetCallbackOnStatus(ghWndCap,(FARPROC)StatusCallbackProc);
capSetCallbackOnFrame(ghWndCap,(FARPROC)FrameCallbackProc);
capDriverConnect(ghWndCap,0); // 将捕获窗同驱动器连接
//获得驱动器的能力,相关的信息放在结构变量gCapDriverCaps中
capDriverGetCaps(ghWndCap,&gCapDriverCaps,sizeof(CAPDRIVERCAPS));
capPreviewRate(ghWndCap, 66); // 设置Preview模式的显示速率
capPreview(ghWndCap, TRUE); //启动Preview模式
if(gCapDriverCaps.fHasOverlay) //检查驱动器是否有叠加能力
capOverlay(ghWndCap,TRUE); //启动Overlay模式
if(gCapDriverCaps.fHasDlgVideoSource)capDlgVideoSource(ghWndCap); //Video source 对话框
if(gCapDriverCaps.fHasDlgVideoFormat)capDlgVideoFormat(ghWndCap); // Video format 对话框
if(gCapDriverCaps.fHasDlgVideoDisplay)capDlgVideoDisplay(ghWndCap); // Video display 对话框
capFileSetCaptureFile( ghWndCap, szCaptureFile); //指定捕获文件名
capFileAlloc(ghWndCap, (1024L * 1024L * 5)); //为捕获文件分配存储空间
capCaptureSequence(ghWndCap); //开始捕获视频序列
capGrabFrame(ghWndCap); //捕获单帧图像

}

return 0;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("Hello,Windows98!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
{
capSetCallbackOnStatus(ghWndCap,NULL);
capSetCallbackOnError(ghWndCap,NULL);
capSetCallbackOnFrame(ghWndCap,NULL);
capCaptureAbort(ghWndCap);//停止捕获
capDriverDisconnect(ghWndCap); //将捕获窗同驱动器断开
PostQuitMessage(0);
}
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}

❷ 易语言怎么做视频监控求源码!QAQ

首先,易语言高!成千上万的源码可以借鉴!
其次够底层,直接嵌入汇编!用上黑月插件,编译够小!
易语言的独特模块,拿来就用!
_
破解,病毒,游戏辅助,基本都是在反编译,掌握了程序基本情况之后,在写程序!!
写内存,读内存,进程注入,这些技术在其他编程语言实现你的看各种文档! 而易语言,各种注入模块,驱动读写内存,都是现成的!
而其他语言,如C语言,你写的时候,很多时间,都是在了解c的各种库。本来你只想吃馒头,用c你就得了解包头的烹饪方法!如果,你还需要互动的界面的话......成本太高了!
易语言很多时候其实只是负责UI,很多动态库都是其他语言编写的,易语言负责调用整合!
可以说,易语言,在开发小程序,有天然的优势!

❸ vb6 无驱摄像头编程 求源码

发下是我几年前写的(参照)一个VB驱动摄像头的代码,不知道现在还能不能用,因为文件总的很长,这只是其中的一小部分,希望对你有所用.(要不就和我联系,给你源码)
Private Sub Form_Load()
On Error Resume Next
Dim retVal As Boolean
Dim numDevs As Long
bCaramaPlaying = True
'load trivial settings first
Me.BackColor = Val(GetSetting(App.Title, "preferences", "backcolor", "&H404040")) 'default to dk gray

numDevs = VBEnumCapDrivers(Me)
If 0 = numDevs Then
MsgBox "没有找到视频捕捉设备!", vbCritical, App.Title
' frmPlayer.Visible = True
' If bIsVisible = True And vbPlayFormIsVisible = True And vbFrmPlayFrameHided = False Then
' frmPlayFrame.Visible = True
' End If
Unload Me
Exit Sub
End If
nDriverIndex = Val(GetSetting(App.Title, "driver", "index", "0"))
'if invalid entry is in registry use default (0)
If mnuDriver.UBound < nDriverIndex Then
nDriverIndex = 0
End If
mnuDriver(nDriverIndex).Checked = True
'//Create Capture Window
'Call capGetDriverDescription( nDriverIndex, lpszName, 100, lpszVer, 100 '// Retrieves driver info
hCapWnd = capCreateCaptureWindow("VB CAP WINDOW", WS_CHILD Or WS_VISIBLE, 0, 0, 160, 120, Me.hWnd, 0)
If 0 = hCapWnd Then
MsgBox "不能创建捕捉窗口!", vbCritical, App.Title
Exit Sub
End If
retVal = ConnectCapDriver(hCapWnd, nDriverIndex)
If False = retVal Then
MsgBox "不能连接到视频设备!", vbInformation, App.Title
Else
#If USECALLBACKS = 1 Then
' if we have a valid capwnd we can enable our status callback function
Call capSetCallbackOnStatus(hCapWnd, AddressOf StatusProc)
Debug.Print "---Callback set on capture status---"
#End If
End If
'// Set the video stream callback function
' capSetCallbackOnVideoStream lwndC, AddressOf MyVideoStreamCallback
' capSetCallbackOnFrame lwndC, AddressOf MyFrameCallback

Dim bPlayFrameTop As Boolean
bPlayFrameTop = GetSetting(MyName, "setting" & "-" & Trim(Str(App.Major)) & "-" & Trim(Str(App.Minor)), "bPlayFrameTop", "False")
If bPlayFrameTop = True Then
Me.mnuOptionTop.Checked = True
'放在最前
SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
Else
Me.mnuOptionTop.Checked = False
'不放在最前
SetWindowPos Me.hWnd, HWND_NOTOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, &H20
End If
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Me.picShowMenu.ZOrder 0

End Sub

'以下是一个模块文件
Option Explicit

'application specific routines are here

Public Const ONE_MEGABYTE As Long = 1048576
'Public Const MMSYSERR_NOERROR As Long = 0
Public Const INDEX_15_MINUTES As Long = 27000 '(30fps * 60sec * 15min)
Public Const INDEX_3_HOURS As Long = 324000 ' (30fps * 60sec * 60min * 3hr)

Public Function GetFreeSpace() As Long
'this function gets the amount of free disk space and adds the size
'of the current capture file
Dim freedisk As Long
Dim path As String

'get Cap File length
path = capFileGetCaptureFile(frmCaramaMain.capwnd)
If path <> "" Then
On Error Resume Next
freedisk = FileLen(path)
freedisk = freedisk / ONE_MEGABYTE
End If

'now get free disk space from that drive
path = Left$(path, 3)
GetFreeSpace = freedisk + vbGetAvailableMBytes(path)

End Function

Sub ResizeCaptureWindow(ByVal hCapWnd As Long)
Dim retVal As Boolean
Dim capStat As CAPSTATUS

'Get the capture window attributes
retVal = capGetStatus(hCapWnd, capStat)

If retVal Then
'Resize the main form to fit
Call SetWindowPos(frmCaramaMain.hWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth + (frmCaramaMain.XBorder * 2), _
capStat.uiImageHeight + (frmCaramaMain.YBorder * 4) _
+ frmCaramaMain.CaptionHeight + frmCaramaMain.MenuHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
'Resize the capture window to format size
Call SetWindowPos(hCapWnd, _
0&, _
0&, _
0&, _
capStat.uiImageWidth, _
capStat.uiImageHeight, _
Swp_nomove Or SWP_NOZORDER Or SWP_NOSENDCHANGING)
End If
Call frmCaramaMain.Form_Resize
End Sub

Public Function VBEnumCapDrivers(ByRef frm As frmCaramaMain) As Long
'/*
' * Enumerate the potential capture drivers and add the list to the Options
' * menu. This function is only called once at startup.
' * Returns 0 if no drivers are available.
' */
Const MAXVIDDRIVERS As Long = 9
Const CAP_STRING_MAX As Long = 128
Dim numDrivers As Long
Dim driverStrings(0 To MAXVIDDRIVERS - 1) As String
Dim Index As Long
Dim Device As String
Dim Version As String
Dim menu As VB.menu

Device = String$(CAP_STRING_MAX, 0)
Version = String$(CAP_STRING_MAX, 0)
numDrivers = 0
For Index = 0 To (MAXVIDDRIVERS - 1) Step 1
If 0 <> capGetDriverDescription(Index, _
Device, _
CAP_STRING_MAX, _
Version, _
CAP_STRING_MAX) _
Then
'extend the menu
If Index > 0 Then
Load frm.mnuDriver(Index)
End If
Set menu = frm.mnuDriver(Index) 'get an object pointer to the new menu
'Concatenate the device name and version strings to the new menu item
menu.Caption = Left$(Device, InStr(Device, vbNullChar) - 1)
menu.Caption = menu.Caption & " "
menu.Caption = menu.Caption & Left$(Version, InStr(Version, vbNullChar) - 1)
menu.Enabled = True
numDrivers = numDrivers + 1
End If

Next
VBEnumCapDrivers = numDrivers
End Function

Public Function ConnectCapDriver(ByVal hCapWnd As Long, ByVal nDriverIndex As Long) As Boolean
Dim retVal As Boolean
Dim Caps As CAPDRIVERCAPS
Dim i As Long

Debug.Assert (nDriverIndex < 10) And (nDriverIndex >= 0)
'// Connect the capture window to the driver
retVal = capDriverConnect(hCapWnd, nDriverIndex)
If False = retVal Then
'return False
Exit Function
End If
'// Get the capabilities of the capture driver
retVal = capDriverGetCaps(hCapWnd, Caps)

If False <> retVal Then
'reset menus (very app-specific)
With frmCaramaMain
For i = 0 To .mnuDriver.UBound
.mnuDriver(i).Checked = False 'make sure all drivers are unchecked
Next
.mnuDriver(nDriverIndex).Checked = True 'then check the new driver
'disable all hardware feature menu items
.mnuSource.Enabled = False
.mnuFormat.Enabled = False
.mnuDisplay.Enabled = False
.mnuOverlay.Enabled = False
'Then enable the ones which are supported by the new driver
If Caps.fHasDlgVideoSource <> 0 Then .mnuSource.Enabled = True
If Caps.fHasDlgVideoFormat <> 0 Then .mnuFormat.Enabled = True
If Caps.fHasDlgVideoDisplay <> 0 Then .mnuDisplay.Enabled = True
If Caps.fHasOverlay <> 0 Then .mnuOverlay.Enabled = True

End With
End If
'// Set the preview rate in milliseconds
Call capPreviewRate(hCapWnd, 66) '15 FPS

'// Start previewing the image from the camera
Call capPreview(hCapWnd, True)
'default to showing a preview each time
frmCaramaMain.mnuPreview.Checked = True

'// Resize the capture window to show the whole image
Call ResizeCaptureWindow(hCapWnd)
ConnectCapDriver = True
End Function
Public Function StatusProc(ByVal hCapWnd As Long, ByVal StatusCode As Long, ByVal lpStatusString As Long) As Long
Select Case StatusCode
Case 0 'this is recommended in docs
'when zero is sent, clear old status messages
'frmCaramaMain.Caption = App.Title
Case IDS_CAP_END ' Video Capture has finished
frmCaramaMain.Caption = App.Title
Case IDS_CAP_STAT_VIDEOAUDIO, IDS_CAP_STAT_VIDEOONLY
MsgBox LPSTRtoVBString(lpStatusString), vbInformation, App.Title
Case Else
'use this function if you need a real VB string
'frmCaramaMain.Caption = LPSTRtoVBString(lpStatusString)

'or, just pass the LPCSTR to a WINAPI function
Call SetWindowTextAsLong(frmCaramaMain.hWnd, lpStatusString)
End Select
Debug.Print "Driver returned code " & StatusCode & " to StatusProc"
StatusProc = -(True) '- converts Boolean to C BOOL
End Function

❹ C# 代码驱动摄像头

using System; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging; using System.Data.SqlTypes; namespace CamVision1 { /// 《summary》 /// 摄像显示区域数据结构设置 /// 《/summary》 public struct CamStruct { public IntPtr handle; public int left; public int top; public int width; public int height; } /// 《summary》 /// 摄像头驱动程序类 /// 《/summary》 public class Cam { private const int WM_USER = 0x400; private const int WS_CHILD = 0x40000000; private const int WS_VISIBLE = 0x10000000; private const int WM_CAP_START = WM_USER; private const int WM_CAP_STOP = WM_CAP_START + 68; private const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10; private const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11; private const int WM_CAP_SAVEDIB = WM_CAP_START + 25; private const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60; private const int WM_CAP_SEQUENCE = WM_CAP_START + 62; private const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20; private const int WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63; private const int WM_CAP_SET_OVERLAY = WM_CAP_START + 51; private const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50; private const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6; private const int WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2; private const int WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3; private const int WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5; private const int WM_CAP_SET_SCALE = WM_CAP_START + 53; private const int WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52; public const int WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1; public const int WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3; public const int WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4; public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7; public const int WM_CAP_GET_USER_DATA = WM_CAP_START + 8; public const int WM_CAP_SET_USER_DATA = WM_CAP_START + 9; public const int WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12; public const int WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13; public const int WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14; public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20; public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21; public const int WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22; public const int WM_CAP_FILE_SAVEAS = WM_CAP_START + 23; public const int WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24; public const int WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25; public const int WM_CAP_EDIT_COPY = WM_CAP_START + 30; public const int WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35; public const int WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36; public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41; public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42; public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43; public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44; public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45; public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46; public const int WM_CAP_GET_STATUS = WM_CAP_START + 54; public const int WM_CAP_SET_SCROLL = WM_CAP_START + 55; public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61; public const int WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64; public const int WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65; public const int WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66; public const int WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67; public const int WM_CAP_ABORT = WM_CAP_START + 69; public const int WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70; public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71; public const int WM_CAP_SINGLE_FRAME = WM_CAP_START + 72; public const int WM_CAP_PAL_OPEN = WM_CAP_START + 80; public const int WM_CAP_PAL_SAVE = WM_CAP_START + 81; public const int WM_CAP_PAL_PASTE = WM_CAP_START + 82; public const int WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83; public const int WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84; // Following added post VFW 1.1 public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85; // Defines end of the message range public const int WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL; private IntPtr hWndC ; private bool bStat; private IntPtr mControlPtr; private int mWidth; private int mHeight; private int mLeft; private int mTop; [DllImport("avicap32.dll")] private static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle,int x,int y,int nWidth,int nHeight, IntPtr hWndParent , int nID); [DllImport("avicap32.dll")] private static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize); [DllImport("User32.dll")] private static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, long lParam); public bool capDlgVideoFormat() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0); } public bool capDlgVideoSource() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0); } public bool capDlgVideoDisplay() { return SendMessage(hWndC, WM_CAP_DLG_VIDEODISPLAY, 0, 0); } public bool capDlgVideoCompression() { return SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0); } /// 《summary》; /// 初始化摄像头 /// 《/summary》 /// 《param name="handle"》控件的句柄《/param》 /// 《param name="left"》开始显示的左边距《/param》 /// 《param name="top"》开始显示的上边距《/param》 /// 《param name="width"》要显示的宽度《/param》 /// 《param name="height"》要显示的长度《/param》 public Cam(CamStruct camStruct) { mControlPtr = camStruct.handle;; mWidth = camStruct.width; mHeight = camStruct.height; mLeft = camStruct.left; mTop = camStruct.top; } /// 《summary》 /// 开始显示图像 /// 《/summary》 public void Start() { if( bStat ) { return; } bStat = true; byte[] lpszName=new byte[99]; hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD | WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr, 0); if (hWndC.ToInt32() != 0 ) { SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0); SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0); SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0); SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0); SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0); SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0); SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0); } return; } /// 《summary》 /// 停止显示 /// 《/summary》 public void Stop() { SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); bStat = false; } /// 《summary》 /// 抓图 /// 《/summary》 /// 《param name="path"》要保存bmp文件的路径《/param》 public void GrabImage(string path) { IntPtr hBmp= Marshal.StringToHGlobalAnsi(path); SendMessage(hWndC, WM_CAP_SAVEDIB, 0, hBmp.ToInt64()); } /// 《summary》 /// 录像 /// 《/summary》 /// 《param name="path"》要保存avi文件的路径《/param》 public void Kinescope(string path) { IntPtr hBmp = Marshal.StringToHGlobalAnsi(path); SendMessage(hWndC, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, hBmp.ToInt64()); SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0); } /// 《summary》 /// 停止录像 /// 《/summary》 public void StopKinescope() { SendMessage(hWndC, WM_CAP_STOP, 0, 0); } } }

❺ 最近,想用MFC编个对话框,能够实时显示摄像头捕捉的镜头!谁有源代码,能否发我一份吧!感激涕零啊……

现在在vc上采集视频常用的方法有三:vfw,directshow,opencv

你是要进行图像处理的话推荐opencv(具体参考:于仕琪,opencv教程基础篇中的例3-6,稍作修改,估计就能用于你的工程)

下面贴出我自己编的一个小工程:如有疑问,E-mail:[email protected]
进行opencv的预备操作你要看那本书和逛opencv中文网

如有问题可以和我讨论(我也是菜鸟,刚为解决了这个问题窃喜不已)。
1.新建mfc对话框工程,在其中添加一个picture控件,除了ID以外什么都不用改

2.在对话框头文件(没有Dlg那个)中添加(最好是在“#include "resource.h" // main symbols之后”):
#include "cxcore.h"
#include "cvcam.h"
#include "windows.h"
#include "cv.h"
#include "highgui.h"
3.在工程-》设置-》选择所有配置-》link(连接)-》对象/库模块-》中添加:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib

4.在需要触发摄像头显示的地方添加:
void CVideomfcDlg::OnButton1()
{
// TODO: Add your control notification handler code here

int ncams = cvcamGetCamerasCount( );//返回可以访问的摄像头数目
HWND MyWin=::GetDlgItem(m_hWnd,IDC_VIDEO); //获得控件句柄(IDC_VIDEO就是图片控件)
cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE); //选择第一个摄像头
int width=240;
int height=240;

cvcamSetProperty(0,CVCAM_PROP_WINDOW, &MyWin); // Selects a window for
cvcamSetProperty(0,CVCAM_RNDWIDTH, &width);
cvcamSetProperty(0,CVCAM_RNDHEIGHT, &height);
cvcamSetProperty(0, CVCAM_PROP_CALLBACK, callback1);
//回调函数将处理每一帧

cvcamInit( );
cvcamStart( );

}
5.改变显示的图像序列大小,在窗口属性设定了以后,添加如下代码:
int width=320; //这个就是需要显示的窗口大小
int height=240; //根据自己需要选择
cvcamSetProperty(0,CVCAM_RNDWIDTH, &width);
cvcamSetProperty(0,CVCAM_RNDHEIGHT, &height);

6.在对话框类中添加callback成员函数(注意,在添加函数的时候,一定要选择static,不选的话你就自己郁闷去吧,反正我是为了这个郁闷了2个礼拜)
void CVideomfcDlg::callback1(IplImage *image)
{

IplImage* image1 = image;
int i,j;

assert (image);
//获取当前系统时间
SYSTEMTIME st2=;
GetLocalTime(&st2);
char sss[18]=; //这个是用来存储所要保存的图片名的,用的是一个笨办法,先定义,再修改其中的数组值。

sss[7]=st2.wHour/10+48; //获取系统当前小时
sss[8]=st2.wHour%10+48;

sss[9]=st2.wMinute/10+48; //获取系统当前分钟
sss[10]=st2.wMinute%10+48;

sss[11]=st2.wSecond/10+48; //获取系统当前秒
sss[12]=st2.wSecond%10+48;

cvSaveImage(sss,image1); //使用系统当前时间为名称(XXXXXX.jpg)存储图片
}
ps:你还需要在c盘根目录下建立一个叫1的文件夹保存图片。
祝你成功!

android 实时监控硬件摄像头如何实现 求个源码

实时监控还是比较厉害的,后台拍摄记录?不懂是个什么意思,程序调用摄像头拍照还是比较简单的。

❼ 求“VC++实现的支持摄像头和图像的人脸识别系统”源码和报告

实现支技摄像头和八图像人脸识别二维码扫描器实现梦想的声音好大。

❽ 求 在网页中打开查看局域网内的摄像头的监控画面 的例子(源码),请不吝赐教,在下感激不尽。

这是正解。。。。

那个监视系统要兼容你用网页打开的操作。
如果不兼容,打死我也没办法,你用的那个软件,如果支持这种调用,应该会写出来。并且会写出详细调用方法、提供源码或直接提供一个网页。
你的监视器是什么端口?网络摄像头么。。
厂商不是傻X,有网页调用的方法,绝对会立刻发布。。。
lz,偶爱莫能助。。。。

阅读全文

与汇编摄像头源码相关的资料

热点内容
鲁班锁解压吗 浏览:395
打包发送文件如何加密 浏览:213
centos解压缩zip 浏览:387
我的世界怎么用命令风块取消指令 浏览:1000
安卓软件请求超时怎么办 浏览:476
androidapp调用另一个app 浏览:621
数控铣床法兰克子程序编程 浏览:173
linux打包命令targz 浏览:996
抖音app是哪个 浏览:407
苹果app怎么上架 浏览:255
NA服务器地址 浏览:427
我的世界如何初始化服务器 浏览:97
哪个手机app天气预报最准 浏览:752
怎样把视频压缩至25m 浏览:570
vivox27文件夹怎么改变 浏览:727
新手玩狼人杀用什么app 浏览:615
pdf在线查看 浏览:954
安卓tv90如何关闭后台 浏览:683
php读取word乱码 浏览:755
minicom源码 浏览:1002