Hi,
I am new to VB and programming on Windows as such. Mostly c++/gcc/linux.
I am trying to build this VB app that shows a streaming video from a camera and that needs to be overlaid with some custom graphics and text.
I used the code published here:
http://www.vb-helper.com/howto_net_video_capture.html
to get the capture part to work. It essentially uses the avicap32.dll that most of you would probably know.
My plan:
1) Capture frames using
and then copy from clipboard.Code:SendMessage(windowHandle, WM_CAP_EDIT_COPY, 0, 0)
2) Do whatever graphics/text overlay on the obtained bitmap
3) send it to some picturebox on some form that is being shown
4) Do step 1 to 3 in a loop by a spawned worker thread.
Firstly is this a reasonable way to do what I want? or is there a much more efficient/easier way to about?
Now the specific problem:
From my main thread directly if I do step 1 to 3 once
It shows me once captured image as it should and all is good.Code:UIComponent.DrawImage(VideoComponent.GetBitmap())
Just to clarify:
UIComponent is an object/instance that launches the Form and owns the picturebox I want to display on.
VideoComponent is an object/instance that has started the videocapture and owns the picturebox to which the video is being captured
But if I wrap the same call above in a function and launch a thread that would start with that function as its starting point, I see a blank screen.
Again, for testing purpose, I am only doing step 1 through 3 just once.
The thread part of the code is like this
I would appreciate if you would let me know what is messed up. I guess I am doing something conceptually wrong somewhere. Also I see the console print messages fine.Code:Private drawthread As Thread public sub main() drawthread = New Thread(AddressOf threadfunc) drawthread.Start() drawthread.Join() end sub Private Sub threadfunc() 'While True Try Console.WriteLine("DBG: Should be drawing image in " & Thread.CurrentThread.GetHashCode) UIComponent.DrawImage(VideoComponent.GetBitmap()) 'Thread.Sleep(500) Catch ex As Exception 'Exit While End Try 'End While End Sub




Reply With Quote