Home > Software engineering >  VB call camera video capture, urgent solution
VB call camera video capture, urgent solution

Time:09-25

 Private Sub Command1_Click () 
SendMessage ctCapWin WM_CAP_Sequence, 0, 0 'start video, video will not return before the end of not
End Sub


Private Sub Command2_Click ()
Image9. Visible=False
Image2. Visible=True

Dim nStyle As Long, T As Long

If ctCapWin=0 Then 'to create a video window, size: 640 * 480
T=Me. ScaleY (200 to Me. The ScaleMode, 3) 'vertical position: video window pixels
'nStyle=WS_Child + WS_Visible + WS_Caption + WS_ThickFrame' child Windows (in Form1) + title bar + + visible border
'nStyle=WS_Child + WS_Visible video window without a title bar and border
NStyle=WS_Visible 'window for independence in the video window, close the main window video window will be automatically closed
CtCapWin=capCreateCaptureWindow (" in the video surveillance, "nStyle, 0, T, 640, 480, Me. HWnd, 0)
End the If
'will be connected to the camera, video window behind if no two statements video window screen will not change
SendMessage ctCapWin WM_CAP_Connect, 0, 0 'connection camera
SendMessage ctCapWin WM_CAP_Set_PreView, 1, 0 ', the third argument: 1 - preview mode effectively, 0 - preview mode is invalid
SendMessage ctCapWin WM_CAP_Set_PreViewRate, 30, 0 'third argument: set the preview display frequency of 30 frames per second
End Sub



Problem that is as described above, two were used respectively to COMMAND the trigger to realize video connection is established and the video is totally no problem, but I use a serial port interrupt receiving instructions in the form of a connection is established, and the video will appear white or stuck phenomenon, very strange, master guidance, thank you

CodePudding user response:

Recommend you a control, our company in use,
VideoCapX, baidu,

CodePudding user response:

A serial port interrupt receiving instructions? How does it work? What is the relationship between and serial port? A camera is a serial port?
And what is your interrupt instruction? You skip the API directly trigger Ring 3 CPU interrupt? But the concept of "serial port interrupt again as DOS,
What do you say? What is really don't understand how your situation?

I know the current relatively popular in the in the Windows of acquisition camera method has two kinds,
1, is the VFW technique, is the capCreateCaptureWindow you use this kind of thing, in fact, you carefully look at the module code, you will find that it's Windows, just wrap the, and no better than you else following SendMessage, is to encapsulate the SendMessage,
See this version of the DX, 2, DirectShow, but high version of the DX no examples of VB6, DX8.1 also,
Relatively using VB6 is the most commonly used VFW, just compatibility is not high, such as the system version, there could be problems such as hardware support,
But for an old system and the fixed hardware fixed see is no big problem on the compatibility,
Compatibility and DirectShow many well, VFW cannot normal access hardware DirectShow can also normal, and high efficiency, well vb6 is it still used VFW, or in other development tools use DirectShow for vb6 can also get a controls,

For the VFW, you can take a look at this example, is collected (don't display can also be collected the bitmap data of cameras)
http://blog.csdn.net/supermanking/article/details/3207341

If you want to know about DirectShow, you can go to the next DX SDK, but the new version of the DX SDK is usually a VC.NET or VB.NET,

CodePudding user response:

Thank you for your advice, I hardware system is this: SCM system as the machine connected to the computer through serial port 232, put on the computer with USB video cameras, sometime work, single chip microcomputer can be started to computer serial port to send a video of instruction, the VB software on the computer to receive the command, the automatically open video window, and start the video until the next bit machine to the computer serial port to send orders to stop the video again, disconnect the camera automatically shut down the video window at this moment, and automatically save the video to the default directory, the basic functions. It happens that I do video acquisition can be alone now, just add a serial port interrupt handlers instruction will be stuck, is to use multithreading??

CodePudding user response:

One serial port command response didn't return to the video, so the card dead,
Needn't multi-threading, just add a Timer control for time delay should be:
A serial port command response in the process of open after the Timer is returned;
After a short period of time delay Timer event is triggered, the Timer to stop, and then began to video,

CodePudding user response:

Can consider to use multiple processes,

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" this suffering,
back "exchange of information using Shared plain text file" shore!

CodePudding user response:

 Private Sub MSComm1_OnComm () 

Dim As Integer I
Dim c As String
Dim S As Integer
Dim N As Integer
Dim H As Integer

On Error GoTo Err

With MSComm1
Select Case mEvent MSComm1.Com
Case comEvReceive
'MSComm1. RThreshold=0
Revbuf=MSComm1. Input
For I=1 To Len (revbuf)
C=Mid (revbuf, I, 1)
TextReceive. Text=TextReceive. Text & amp; C 'output shows
Next I

If Mid (revbuf, 1, 1)="S" Then "to receive the string is in line with the requirements, the other receiving string length should be increased by doing judgment.
Image2. Visible=False
Image9. Visible=True
Label1. Caption=Mid (revbuf, 2, 3)
Label2. Caption=Mid (revbuf, 6, 3)

End the If
If Mid (revbuf, 1, 1)="H" Then "to receive the string is in line with the requirements, the other receiving string length should be increased by doing judgment.
Label3. Caption=Mid (revbuf, 2, 2)

End the If

Call jieshou

'MSComm1. RThreshold=1

End the Select

End With
Revbuf=""
Err:
End Sub

The Public Function jieshou ()

Dim data (1) the As Byte
Dim nStyle As Long, T As Long

The Select Case revbuf

Case "count=1;"

If ctCapWin=0 Then 'to create a video window, size: 640 * 480

T=Me. ScaleY (200 to Me. The ScaleMode, 3) 'vertical position: video window pixels
'nStyle=WS_Child + WS_Visible + WS_Caption + WS_ThickFrame' child Windows (in Form1) + title bar + + visible border
'nStyle=WS_Child + WS_Visible video window without a title bar and border
NStyle=WS_Visible 'window for independence in the video window, close the main window video window will be automatically closed
CtCapWin=capCreateCaptureWindow (" in the video surveillance, "nStyle, 0, T, 640, 480, Me. HWnd, 0)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related