當前位置:首頁 » 操作系統 » 網路攝像機源碼

網路攝像機源碼

發布時間: 2023-06-11 12:55:55

⑴ 使用VB語言編寫,在界面上畫個框,裡面顯示攝像頭里的圖像

就是用攝像頭來拍個照嘛...

'一個VB製作攝像頭拍照的源碼,如下:
"avicap32.dll"_
Alias"capCreateCaptureWindowA"(_
ByVallpszWindowNameAsString,_
ByValdwStyleAsLong,_
ByValxAsLong,_
ByValyAsLong,_
ByValnWidthAsLong,_
ByValnHeightAsLong,_
ByValhWndParentAsLong,_
ByValnIDAsLong)AsLong
PrivateConstWS_CHILD=&H40000000
PrivateConstWS_VISIBLE=&H10000000
PrivateConstWM_USER=&H400
PrivateConstWM_CAP_START=&H400
PrivateConstWM_CAP_EDIT_COPY=(WM_CAP_START+30)
PrivateConstWM_CAP_DRIVER_CONNECT=(WM_CAP_START+10)
PrivateConstWM_CAP_SET_PREVIEWRATE=(WM_CAP_START+52)
PrivateConstWM_CAP_SET_OVERLAY=(WM_CAP_START+51)
PrivateConstWM_CAP_SET_PREVIEW=(WM_CAP_START+50)
PrivateConstWM_CAP_DRIVER_DISCONNECT=(WM_CAP_START+11)
PrivatePreview_HandleAsLong
"user32"_
Alias"SendMessageA"(_
ByValhwndAsLong,_
ByValwMsgAsLong,_
ByValwParamAsLong,_
lParamAsAny)AsLong
PrivateFunctionCapturePicture(nCaptureHandleAsLong)AsStdPicture
Clipboard.Clear
SendMessagenCaptureHandle,WM_CAP_EDIT_COPY,0,0
SetCapturePicture=Clipboard.GetData
EndFunction
PrivateSubcmdCap_Click()
Picture1.Picture=CapturePicture(Preview_Handle)
EndSub
PrivateSubcmdSave_Click()
OnErrorResumeNext
SavePicturePicture1.Picture,"C:"&Format(Date,"dd-MM-yyyy")&""&Format(Time,"hh-mm-ss")&".bmp"
EndSub
PrivateSubForm_Load()
Preview_Handle=capCreateCaptureWindow("Video",WS_CHILD+WS_VISIBLE,2,2,320,240,Me.hwnd,1)
SendMessagePreview_Handle,WM_CAP_DRIVER_CONNECT,0,0
SendMessagePreview_Handle,WM_CAP_SET_PREVIEWRATE,1,0
SendMessagePreview_Handle,WM_CAP_SET_PREVIEW,1,0
EndSub
PrivateSubForm_Unload(CancelAsInteger)
SendMessagePreview_Handle,WM_CAP_DRIVER_DISCONNECT,0,0
EndSub

⑵ 怎樣用源碼編程器編程攝像頭游戲

攝像頭是游戲陪玩app源碼進行視頻連麥時的重要移動設備之一,在開發時,我們需要實現游戲陪玩app源碼對攝像頭的調用許可權,這就涉及到相關介面的開發了,不過今天我們主要來了解一下在游戲陪玩app源碼開發中,攝像頭調用和視頻處理的相關知識點。
打開攝像頭步驟為:

1、檢查攝像頭;
2、打開攝像頭;
3、設置攝像頭參數;
4、設置預覽界面。

⑶ 求一個控制攝像頭小程序的源碼,要求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);
}

⑷ 使用c#編寫攝像頭程序,可以拍照,錄像,保存到本地。求源碼,可以直接運行的。

你沒有釋放資源。這個問題和我遇到的一模一樣。在關閉攝像頭的程序段中加上釋放資源的語句。

⑸ 求用C#抓取USB攝像頭程序源碼

用C#捕獲攝像頭

你自己去瞧瞧吧!

⑹ 易語言伺服器端怎麼連接客戶端的攝像頭!最好有一個簡單的源碼 就連接一個攝像頭

所用組件和支持庫、變數:

一、接收端程序編寫
1.支持庫:視頻聊天支持庫
2.接送端全局變數及組件
全局變數 音頻輸出設備, 文本型
組件 多媒體播放器 說明:播放接收到的視頻圖像
組件伺服器說明:接收視頻數據
組件時鍾 說明:用於檢測接收遠程資料庫速度
組件標簽 說明:顯示接收遠程數據數據速度
組件 窗口1 說明:設置輸出音頻
組件多媒體設備枚舉器 說明:獲取音頻設備
組件組合框 說明:列出音頻設備

3.接收視頻窗口設置-啟動窗口 .版本2
.支持庫eChat

.程序集窗口程序集2
.程序集變數視頻輸入設備數組,視頻輸入設備,,"0"
.程序集變數音頻輸入設備數組,音頻輸入設備,,"0"

.子程序_窗口1_創建完畢
.局部變數n,整數型

視頻輸入設備數組=多媒體設備枚舉器1.取視頻輸入設備列表()
音頻輸入設備數組=多媒體設備枚舉器1.取音頻輸入設備列表()
.計次循環首(取數組成員數(視頻輸入設備數組),n)
組合框_視頻輸入.加入項目(視頻輸入設備數組[n].設備名稱,)
.計次循環尾()
組合框_視頻輸入.現行選中項=0
.計次循環首(取數組成員數(音頻輸入設備數組),n)
組合框_音頻輸入.加入項目(音頻輸入設備數組[n].設備名稱,)
.計次循環尾()
組合框_音頻輸入.現行選中項=0


.子程序_按鈕1_被單擊

視頻輸入設備=視頻輸入設備數組[組合框_視頻輸入.現行選中項+1].設備路徑
音頻輸入設備=音頻輸入設備數組[組合框_音頻輸入.現行選中項+1].設備標識
銷毀()

發送端設置完成。

⑺ C# 如何採集 視頻和音頻 如何調用攝像頭獲取圖片

C#操作視頻是通過調用專門的硬體廠商提供的sdk來完成的,比如你想要調用漢邦、大華等攝像頭生產廠商,那麼你去他們的官方網站下載慎宴祥sdk包,然後通過調用動態鏈接庫的方式調用函數就行了。不過有很多動態鏈接庫是C++寫的,所以你可能祥咐要查找關於寬搏C#如何調用C++編寫的動態鏈接庫的方法,其實也就是一些變數類型的轉換問題。
希望能幫助到你。

⑻ 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

熱點內容
androidstudio閃退 發布:2025-04-05 12:35:54 瀏覽:897
騰訊視頻青少年模式原始密碼是多少 發布:2025-04-05 12:27:21 瀏覽:536
企業文檔存儲管理系統 發布:2025-04-05 12:21:20 瀏覽:749
php計算字元串 發布:2025-04-05 12:09:45 瀏覽:704
安卓版快手實驗室在哪裡 發布:2025-04-05 11:59:15 瀏覽:561
系統文件夾加密 發布:2025-04-05 11:55:17 瀏覽:172
python獲取坐標 發布:2025-04-05 11:49:44 瀏覽:938
excel2003加密方法 發布:2025-04-05 11:32:30 瀏覽:852
公司路由器地址改變伺服器地址 發布:2025-04-05 11:32:27 瀏覽:501
帝豪第四代豪華型有哪些配置 發布:2025-04-05 11:31:41 瀏覽:14