當前位置:首頁 » 編程軟體 » 攝影頭編程

攝影頭編程

發布時間: 2022-05-28 23:21:59

❶ 如何使用MATLAB進行USB2.0攝像頭的編程

Matlab中的圖像獲取工具箱給我們提供了必要的函數,我們直接調用就可以了。在在這帖中我們主要就是簡單的介紹如何使用該工具箱進行對USB2.0攝像頭的編程

廢話不多說,我們開始言歸正傳了。但是一定記住你必須安裝了PC攝像頭才可以進行下面的東西,如果說首次安裝攝像頭最好重啟下PC,否則可能出現沒法識別攝像頭。

整個過程我們需要做如下幾件事情:
1、查詢USB2.0Camera 的具體參數(imaqhwinfo)
2、創建視頻輸入對象(videoinput)
3、圖像預覽和顯示(preview、stoppreview、closepreview和image)
4、獲取視頻圖像(getsnapshot)
5、圖像獲取設備的獲取和設置(get和set)
6、關閉視頻對象(delete)

在正式講解之前,我想說明下幾個個在圖像獲取工具箱中的術語:

圖像獲取設備:比如攝像頭、掃描儀
圖像獲取適配器:主要的目的是通過驅動在Matlab和圖像獲取設備之間傳遞信息
ROI:region-of-interest 感興趣區域

在說說幾個常用的函數,我們這里只是說明它的作用,具體如何使用參考幫助系統
getselectedsource
imaqfind
isvalid
peekdata
getdata
imaqmontage
給我們一個攝像頭我們必須知道他的相關參數,才可能進行我們的編程下。當然我們可以查詢商家手冊,但是那個累不累人呀。

Matlab的圖像獲取工具箱為我提供了imaqhwinfo(),來獲取PC上以安裝的圖像獲取硬體信息

❷ 在編程中怎樣調用攝像頭

在編程裡面想要調用了攝像頭的話,這個你可以給他編輯一個程序,然後就打開攝像頭就可以了。

❸ 嵌入式攝像頭編程要涉及到哪些知識

linux驅動和移植

❹ c# 攝像頭編程

建議你使用AVICap class API(avicap32.dll)來進行攝像頭編程,你用的是.net,所以請使用平台Invoke(P/Invoke)來使用該API.
給你點相關代碼:
1.
using System.Runtime.InteropServices;
2.
const int WM_CAP_START = 1024;
const int WS_CHILD = 1073741824;
const int WS_VISIBLE = 268435456;
const int WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10);
const int WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11);
const int WM_CAP_EDIT_COPY = (WM_CAP_START + 30);
const int WM_CAP_SEQUENCE = (WM_CAP_START + 62);
const int WM_CAP_FILE_SAVEAS = (WM_CAP_START + 23);
const int WM_CAP_SET_SCALE = (WM_CAP_START + 53);
const int WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52);
const int WM_CAP_SET_PREVIEW = (WM_CAP_START + 50);
const int SWP_NOMOVE = 2;
const int SWP_NOSIZE = 1;
const int SWP_NOZORDER = 4;
const int HWND_BOTTOM = 1;

3.
//---capGetDriverDescription函數取得捕獲驅動的版本描述信息 [System.Runtime.InteropServices.DllImport("avicap32.dll")]
static extern bool capGetDriverDescriptionA(
short wDriverIndex, string lpszName,
int cbName, string lpszVer, int cbVer);
//---capCreateCaptureWindow函數建立一個捕獲窗口
[System.Runtime.InteropServices.DllImport("avicap32.dll")]
static extern int capCreateCaptureWindowA(
string lpszWindowName, int dwStyle, int x, int y,
int nWidth, short nHeight, int hWnd, int nID);
//---SendMessageA
[System.Runtime.InteropServices.DllImport(
"user32", EntryPoint = "SendMessageA")]
static extern int SendMessage(
int hwnd, int Msg, int wParam,
[MarshalAs(UnmanagedType.AsAny)] object lParam);
//---SetWindowPos
[System.Runtime.InteropServices.DllImport(
"user32", EntryPoint = "SetWindowPos")]
static extern int SetWindowPos(
int hwnd, int hWndInsertAfter, int x, int y,
int cx, int cy, int wFlags);
//--DestroyWindow
[System.Runtime.InteropServices.DllImport("user32")]
static extern bool DestroyWindow(int hndw);

4.
//---定義窗口句柄---
private int hWnd;

5.
private void Form1_Load(object sender, EventArgs e)
{
if (serialPort.IsOpen)
{
serialPort.Close();
}
try
{
//---配置串口參數
serialPort.PortName = "COM3";
serialPort.BaudRate = 9600;
serialPort.Parity = System.IO.Ports.Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = System.IO.Ports.StopBits.One;
serialPort.Handshake = System.IO.Ports.Handshake.None;
serialPort.DataReceived +=
new
System.IO.Ports.(
DataReceived);
//打開串口
serialPort.Open();
serialPort.DiscardInBuffer();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
//視頻顯示
PreviewVideo(PictureBox1);
}

6.
private void PreviewVideo(PictureBox pbCtrl)
{
hWnd = capCreateCaptureWindowA(
"0", WS_VISIBLE | WS_CHILD, 0, 0, 0, 0,
pbCtrl.Handle.ToInt32(), 0);
if (SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0) != 0)
{
//---set the preview scale---
SendMessage(hWnd, WM_CAP_SET_SCALE, 1, 0);
//---set the preview rate (ms)---
SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0);
//---start previewing the image---
SendMessage(hWnd, WM_CAP_SET_PREVIEW, 1, 0);
//---resize window to fit in PictureBox control---
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0,
pbCtrl.Width, pbCtrl.Height,
SWP_NOMOVE | SWP_NOZORDER);
}
else
{
//錯誤連接
DestroyWindow(hWnd);
}
}

❺ linux下怎麼樣進行攝像頭編程

在linux下所有設備都是文件。所以對攝像頭的操作其實就是對文件的操作。USB攝像頭的設備文件就是在/dev目錄下的video0(假如只有一個攝像頭)。在linux下操作攝像頭就是使用v4l2對攝像頭進行的操作,操作步驟如下

  • 打開設備文件。

  • int fd=open(」/dev/video0″,O_RDWR);

  • 2. 取得設備的capability,看看設備具有什麼功能,比如是否具有輸入,或者音頻輸入輸出等。VIDIOC_QUERYCAP,struct v4l2_capability

  • v4l2_std_id std;

  • do {

  • ret= ioctl(fd, VIDIOC_QUERYSTD, std);

  • } while (ret == -1 errno == EAGAIN);

  • switch (std) {

  • case V4L2_STD_NTSC:

  • //……

  • case V4L2_STD_PAL:

  • //……

  • }

  • 3. 選擇輸入,一個設備可以有多個輸入。VIDIOC_S_INPUT,struct v4l2_input(可不要)

  • 4. 設置的制式和幀格式,制式包括PAL,NTSC,幀的格式個包括寬度和高度等。

  • VIDIOC_S_STD,VIDIOC_S_FMT,struct v4l2_std_id,struct v4l2_format

  • struct v4l2_format fmt;

  • memset ( fmt, 0, sizeof(fmt) );

  • fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  • fmt.fmt.pix.width = 320;

  • fmt.fmt.pix.height = 240;

  • fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;

  • if (ioctl(fd, VIDIOC_S_FMT, fmt) < 0)

  • {

  • printf("set format failed ");

  • //return 0;

  • }

  • 5. 向驅動申請幀緩沖,一般不超過5個。struct v4l2_requestbuffers

  • struct v4l2_requestbuffers req;

  • memset(req, 0, sizeof (req));

  • req.count = 4;

  • req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  • req.memory = V4L2_MEMORY_MMAP;

  • if (ioctl(fd,VIDIOC_REQBUFS,req) == -1)

  • {

  • perror("VIDIOC_REQBUFS error ");

  • //return -1;

  • }

  • 6.申請物理內存

  • 將申請到的幀緩沖映射到用戶空間,這樣就可以直接操作採集到的幀了,而不必去復制。將申請到的幀緩沖全部入隊列,以便存放採集到的數據.VIDIOC_QBUF,struct v4l2_buffer

  • VideoBuffer* buffers = calloc( req.count, sizeof(VideoBuffer) );

  • printf("sizeof(VideoBuffer) is %d ",sizeof(VideoBuffer));

  • struct v4l2_buffer buf;

  • for (numBufs = 0; numBufs < req.count; numBufs++)

  • {

  • memset( buf, 0, sizeof(buf) );

  • buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  • buf.memory = V4L2_MEMORY_MMAP;

  • buf.index = numBufs;

  • if (ioctl(fd, VIDIOC_QUERYBUF, buf) < 0)

  • {

  • printf("VIDIOC_QUERYBUF error ");

  • //return -1;

  • }

  • printf("buf len is %d ",sizeof(buf));

  • //內存映射

  • buffers[numBufs].length = buf.length;

  • buffers[numBufs].offset = (size_t) buf.m.offset;

  • buffers[numBufs].start = mmap (NULL, buf.length,PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset);

  • printf("buffers.length = %d,buffers.offset = %d ,buffers.start[0] = %d ",buffers[numBufs].length,buffers[numBufs].offset,buffers[numBufs].start[0]);

  • printf("buf2 len is %d ",sizeof(buffers[numBufs].start));

  • if (buffers[numBufs].start == MAP_FAILED)

  • {

  • perror("buffers error ");

  • //return -1;

  • }

  • if (ioctl (fd, VIDIOC_QBUF, buf) < 0)

  • {

  • printf("VIDIOC_QBUF error ");

  • //return -1;

  • }

  • }

  • 7. 開始的採集。

  • enum v4l2_buf_type type;

  • type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  • if (ioctl (fd, VIDIOC_STREAMON, type) < 0)

  • {

  • printf("VIDIOC_STREAMON error ");

  • // return -1;

  • }

  • 8. 出隊列以取得已採集數據的幀緩沖,取得原始採集數據。VIDIOC_DQBUF, 將緩沖重新入隊列尾,這樣可以循環採集。VIDIOC_QBUF

  • if (ioctl(fd, VIDIOC_DQBUF, buf) < 0)

  • {

  • perror("VIDIOC_DQBUF failed. ");

  • //return -1;

  • }

  • buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  • buf.memory = V4L2_MEMORY_MMAP;

  • unsigned char *ptcur = buffers[numBufs].start;

  • DEBUG("buf.bytesused = %d ",buf.bytesused);

  • int i1;

  • for(i1=0; i1<buf.bytesused; i1++)

  • {

  • if((buffers[numBufs].start[i1] == 0xFF) (buffers[numBufs].start[i1+1] == 0xC4))

  • {

  • DEBUG("huffman table finded! buf.bytesused = %d FFC4 = %d ",buf.bytesused,i1);

  • break;

  • }

  • }

  • if(i1 == buf.bytesused)printf("huffman table don't exist! ");

  • int i;

  • for(i=0; i<buf.bytesused; i++)

  • {

  • if((buffers[numBufs].start[i] == 0xFF) (buffers[numBufs].start[i+1] == 0xD8)) break;

  • ptcur++;

  • }

  • DEBUG("i=%d,FF=%02x,D8=%02x ",i,buffers[numBufs].start[i],buffers[numBufs].start[i+1]);

  • int imagesize =buf.bytesused - i;

  • DEBUG("buf.bytesused = %d ",buf.bytesused);

  • DEBUG ("imagesize = %d ",imagesize);

  • 9. 停止的採集。VIDIOC_STREAMOFF

  • 10. 關閉設備。close(fd);

❻ 如何編程使網路攝像頭監測有東西在移動

這應該說圖像檢測和處理的內容。很多圖書把它歸為人工智慧的范疇。

我有一個思路供你參考。
如果攝像頭是固定的話,那它拍攝的背景是相同的。
攝像機就是連續快速拍攝的照相機。

攝像頭以每秒若干張照片的速度拍攝。

這些照片顯示的應該是連續的畫面。
而檢測畫面是否在運動,就是比較前後兩張圖片是否存在差異。

以上是基本思路,程序可以直接從攝像頭上獲取圖像信息,也可從視頻文件中獲取圖像信息。

不過在實際實現上還是有改進的地方,
比如是檢測前後兩張圖片的話,檢測的敏感程度太高了。
比如,攝像頭前飛來一隻蚊子,它也能察覺到,而你也許只想看到是否有人或車輛在動。或者背景上有一些植物在動,而這不是你需要。
可以對這個規則進行適當修改。
比如檢測前後連續若干張圖片,如果圖片的差異度不大的話,算做沒有差異。
以及兩張圖片之間的差異度如何計算都可以適當規定。

❼ linux下怎樣進行攝像頭編程

在linux下所有設備都是文件。所以對攝像頭的操作其實就是對文件的操作。USB攝像頭的設備文件就是在/dev目錄下的video0(假如只有一個攝像頭)。在linux下操作攝像頭就是使用v4l2對攝像頭進行的操作,操作步驟如下

  1. 打開設備文件。

  2. int fd=open(」/dev/video0″,O_RDWR);

  3. 2. 取得設備的capability,看看設備具有什麼功能,比如是否具有輸入,或者音頻輸入輸出等。VIDIOC_QUERYCAP,struct v4l2_capability

  4. v4l2_std_id std;

  5. do {

  6. ret= ioctl(fd, VIDIOC_QUERYSTD, std);

  7. } while (ret == -1 errno == EAGAIN);

  8. switch (std) {

  9. case V4L2_STD_NTSC:

  10. //……

  11. case V4L2_STD_PAL:

  12. //……

  13. }

  14. 3. 選擇輸入,一個設備可以有多個輸入。VIDIOC_S_INPUT,struct v4l2_input(可不要)

  15. 4. 設置的制式和幀格式,制式包括PAL,NTSC,幀的格式個包括寬度和高度等。

  16. VIDIOC_S_STD,VIDIOC_S_FMT,struct v4l2_std_id,struct v4l2_format

  17. struct v4l2_format fmt;

  18. memset ( fmt, 0, sizeof(fmt) );

  19. fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  20. fmt.fmt.pix.width = 320;

  21. fmt.fmt.pix.height = 240;

  22. fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG;

  23. if (ioctl(fd, VIDIOC_S_FMT, fmt) < 0)

  24. {

  25. printf("set format failed ");

  26. //return 0;

  27. }

  28. 5. 向驅動申請幀緩沖,一般不超過5個。struct v4l2_requestbuffers

  29. struct v4l2_requestbuffers req;

  30. memset(req, 0, sizeof (req));

  31. req.count = 4;

  32. req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  33. req.memory = V4L2_MEMORY_MMAP;

  34. if (ioctl(fd,VIDIOC_REQBUFS,req) == -1)

  35. {

  36. perror("VIDIOC_REQBUFS error ");

  37. //return -1;

  38. }

  39. 6.申請物理內存

  40. 將申請到的幀緩沖映射到用戶空間,這樣就可以直接操作採集到的幀了,而不必去復制。將申請到的幀緩沖全部入隊列,以便存放採集到的數據.VIDIOC_QBUF,struct v4l2_buffer

  41. VideoBuffer* buffers = calloc( req.count, sizeof(VideoBuffer) );

  42. printf("sizeof(VideoBuffer) is %d ",sizeof(VideoBuffer));

  43. struct v4l2_buffer buf;

  44. for (numBufs = 0; numBufs < req.count; numBufs++)

  45. {

  46. memset( buf, 0, sizeof(buf) );

  47. buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  48. buf.memory = V4L2_MEMORY_MMAP;

  49. buf.index = numBufs;

  50. if (ioctl(fd, VIDIOC_QUERYBUF, buf) < 0)

  51. {

  52. printf("VIDIOC_QUERYBUF error ");

  53. //return -1;

  54. }

  55. printf("buf len is %d ",sizeof(buf));

  56. //內存映射

  57. buffers[numBufs].length = buf.length;

  58. buffers[numBufs].offset = (size_t) buf.m.offset;

  59. buffers[numBufs].start = mmap (NULL, buf.length,PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset);

  60. printf("buffers.length = %d,buffers.offset = %d ,buffers.start[0] = %d ",buffers[numBufs].length,buffers[numBufs].offset,buffers[numBufs].start[0]);

  61. printf("buf2 len is %d ",sizeof(buffers[numBufs].start));

  62. if (buffers[numBufs].start == MAP_FAILED)

  63. {

  64. perror("buffers error ");

  65. //return -1;

  66. }

  67. if (ioctl (fd, VIDIOC_QBUF, buf) < 0)

  68. {

  69. printf("VIDIOC_QBUF error ");

  70. //return -1;

  71. }

  72. }

  73. 7. 開始的採集。

  74. enum v4l2_buf_type type;

  75. type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  76. if (ioctl (fd, VIDIOC_STREAMON, type) < 0)

  77. {

  78. printf("VIDIOC_STREAMON error ");

  79. // return -1;

  80. }

  81. 8. 出隊列以取得已採集數據的幀緩沖,取得原始採集數據。VIDIOC_DQBUF, 將緩沖重新入隊列尾,這樣可以循環採集。VIDIOC_QBUF

  82. if (ioctl(fd, VIDIOC_DQBUF, buf) < 0)

  83. {

  84. perror("VIDIOC_DQBUF failed. ");

  85. //return -1;

  86. }

  87. buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

  88. buf.memory = V4L2_MEMORY_MMAP;

  89. unsigned char *ptcur = buffers[numBufs].start;

  90. DEBUG("buf.bytesused = %d ",buf.bytesused);

  91. int i1;

  92. for(i1=0; i1<buf.bytesused; i1++)

  93. {

  94. if((buffers[numBufs].start[i1] == 0xFF) (buffers[numBufs].start[i1+1] == 0xC4))

  95. {

  96. DEBUG("huffman table finded! buf.bytesused = %d FFC4 = %d ",buf.bytesused,i1);

  97. break;

  98. }

  99. }

  100. if(i1 == buf.bytesused)printf("huffman table don't exist! ");

  101. int i;

  102. for(i=0; i<buf.bytesused; i++)

  103. {

  104. if((buffers[numBufs].start[i] == 0xFF) (buffers[numBufs].start[i+1] == 0xD8)) break;

  105. ptcur++;

  106. }

  107. DEBUG("i=%d,FF=%02x,D8=%02x ",i,buffers[numBufs].start[i],buffers[numBufs].start[i+1]);

  108. int imagesize =buf.bytesused - i;

  109. DEBUG("buf.bytesused = %d ",buf.bytesused);

  110. DEBUG ("imagesize = %d ",imagesize);

  111. 9. 停止的採集。VIDIOC_STREAMOFF

  112. 10. 關閉設備。close(fd);

❽ VB.NET 攝像頭編程求助

這是6.0的,.net的做些改動就成!因為我沒裝攝像頭,就沒改! Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" _ Alias "capCreateCaptureWindowA" ( _ ByVal lpszWindowName As String, _ ByVal dwStyle As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hWndParent As Long, _ ByVal nID As Long) As Long Private Const WS_CHILD = &H40000000 Private Const WS_VISIBLE = &H10000000 Private Const WM_USER = &H400 Private Const WM_CAP_START = &H400 Private Const WM_CAP_EDIT_COPY = (WM_CAP_START + 30) Private Const WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10) Private Const WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52) Private Const WM_CAP_SET_OVERLAY = (WM_CAP_START + 51) Private Const WM_CAP_SET_PREVIEW = (WM_CAP_START + 50) Private Const WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11) Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Preview_Handle As Long Public Function CreateCaptureWindow( _ hWndParent As Long, _ Optional x As Long = 0, _ Optional y As Long = 0, _ Optional nWidth As Long = 320, _ Optional nHeight As Long = 240, _ Optional nCameraID As Long = 0) As Long Preview_Handle = capCreateCaptureWindow("Video", _ WS_CHILD + WS_VISIBLE, x, y, _ nWidth, nHeight, hWndParent, 1) SendMessage Preview_Handle, WM_CAP_DRIVER_CONNECT, nCameraID, 0 SendMessage Preview_Handle, WM_CAP_SET_PREVIEWRATE, 30, 0 SendMessage Preview_Handle, WM_CAP_SET_OVERLAY, 1, 0 SendMessage Preview_Handle, WM_CAP_SET_PREVIEW, 1, 0 CreateCaptureWindow = Preview_Handle End Function Public Function CapturePicture(nCaptureHandle As Long) As StdPicture Clipboard.Clear SendMessage nCaptureHandle, WM_CAP_EDIT_COPY, 0, 0 Set CapturePicture = Clipboard.GetData End Function Public Sub Disconnect(nCaptureHandle As Long, _ Optional nCameraID = 0) SendMessage nCaptureHandle, WM_CAP_DRIVER_DISCONNECT, _ nCameraID, 0 End Sub 4在form上添加一個PictureBox,一個按鈕,Caption設為 Save Pic Dim Video_Handle As Long Private Sub Form_Load() Video_Handle = CreateCaptureWindow(PicCapture.hwnd) End Sub Private Sub Command1_Click() Dim x As StdPicture Set x = CapturePicture(Video_Handle) SavePicture x, "c:\a.bmp" End Sub Private Sub Form_Unload(Cancel As Integer) Disconnect Video_Handle End Sub 追問: 可不可以幫忙寫為VB.NET的程序..?我自己運行後顯示 未聲明 PicCapture 追問: nCameraID = 0 這里在VB.NET下也用不了Clipboard.GetData 在VB.NET里也要跟參數的..我自己試用VB可以的..希望你能幫忙寫一個VB.NET的..因為就算沒有攝像頭picturebox也會顯示黑色的 回答: 你這程序是工程用的!請加多點分!我給你改 追問: 可不可以加我QQ先344568960 因為我積分不多...或許我可以給Q幣你怎麼的~可以嗎? 追問: 已經補充了積分了~希望能幫忙改成VB.NET的吧~謝謝~ 回答: 建一個picturebox 和 button Imports System.Runtime.InteropServices Public Class Form1 Const WM_CAP_START = &H400S Const WS_CHILD = &H40000000 Const WS_VISIBLE = &H10000000 Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11 Const WM_CAP_EDIT_COPY = WM_CAP_START + 30 Const WM_CAP_SEQUENCE = WM_CAP_START + 62 Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23 Const WM_CAP_SET_SCALE = WM_CAP_START + 53 Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50 Const SWP_NOMOVE = &H2S Const SWP_NOSIZE = 1 Const SWP_NOZORDER = &H4S Const HWND_BOTTOM = 1 Dim hWnd As Integer Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _ (ByVal wDriverIndex As Short, _ ByVal lpszName As String, ByVal cbName As Integer, _ ByVal lpszVer As String, _ ByVal cbVer As Integer) As Boolean Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _ (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _ ByVal x As Integer, ByVal y As Integer, _ ByVal nWidth As Integer, _ ByVal nHeight As Short, ByVal hWnd As Integer, _ ByVal nID As Integer) As Integer Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Integer, ByVal Msg As Integer, _ ByVal wParam As Integer, _ <Runtime.InteropServices.MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) _ As Integer Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _ (ByVal hwnd As Integer, _ ByVal hWndInsertAfter As Integer, ByVal x As Integer, _ ByVal y As Integer, _ ByVal cx As Integer, ByVal cy As Integer, _ ByVal wFlags As Integer) As Integer Declare Function DestroyWindow Lib "user32" _ (ByVal hndw As Integer) As Boolean Private Sub PreviewVideo(ByVal pbCtrl As PictureBox) hWnd = capCreateCaptureWindowA(0, _ WS_VISIBLE Or WS_CHILD, 0, 0, 0, _ 0, pbCtrl.Handle.ToInt32, 0) If SendMessage( _ hWnd, WM_CAP_DRIVER_CONNECT, _ 0, 0) Then SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0) SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _ pbCtrl.Width, pbCtrl.Height, _ SWP_NOMOVE Or SWP_NOZORDER) Else DestroyWindow(hWnd) End If End Sub Private Sub Form1_Load( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load PreviewVideo(PictureBox1) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim data As IDataObject Dim bmap As Image SendMessage(hWnd, WM_CAP_EDIT_COPY, 0, 0) data = Clipboard.GetDataObject() If data Is Nothing Then Exit Sub If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then bmap = CType(data.GetData(GetType( _ System.Drawing.Bitmap)), Image) bmap.Save("d:\a.bmp", System.Drawing.Imaging.ImageFormat.Bmp) MsgBox("完成") End If End Sub End Class

c語言進行攝像頭編程需要學些什麼

directshow/avicapture/opencv幾種都可以實現,好好學這幾方面吧 ,不對,弄清楚其中一種先。但是,基本語法知識就有點...C知識先搞清楚。

❿ 如何實現在電腦上編程實現對攝像頭的控制

你說的是對對方的攝像頭進行控制嗎?
這個常人做不到的 因為你要建立一個連接,也就相當於你是伺服器,你還得打開一個通往他的埠,還要越過對方的防火牆和殺毒軟體

你如果沒有C++基礎可以用易語言弄,不過太麻煩了

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:649
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:940
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:635
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:824
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:734
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1070
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:302
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:164
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:855
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:766