-
Jan 15th, 2021, 12:29 PM
#1
Thread Starter
Member
Draw On Camera Preview screen in VB2010
Hello everyone,
Hope you all the doing awesome !!
I am working on capturing video via accessing the camera of my laptop in visual basic 2010. the code works fine but when I try to draw any shape on it- my code just do not work - no error but there is no shape. I think i do not know how to draw on camera preview screen.
here is my code-
Code:
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
DeviceID = lstDevices.SelectedIndex
OpenPreviewWindow()
Dim bReturn As Boolean
Dim s As CAPSTATUS
bReturn = SendMessage(hHwnd, WM_CAP_GET_STATUS, Marshal.SizeOf(s), s)
Debug.WriteLine(String.Format("Video Size {0} x {1}", s.uiImageWidth, s.uiImageHeight))
End Sub
Private Sub btnInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInfo.Click
Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.FillRectangle(myBrush, New Rectangle(50, 9, 200, 30))
picCapture.SendToBack()
' SendMessage(hHwnd, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
SendMessage(hHwnd, WM_CAP_DLG_VIDEOFORMAT, True, 0)
End Sub
Private Sub Frm_camera_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadDeviceList()
If lstDevices.Items.Count > 0 Then
btnStart.Enabled = True
lstDevices.SelectedIndex = 0
btnStart.Enabled = True
Else
lstDevices.Items.Add("No Capture Device")
btnStart.Enabled = False
End If
'Me.AutoScrollMinSize = New Size(100, 100)
picCapture.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Last edited by si_the_geek; Jan 15th, 2021 at 12:37 PM.
Reason: fixed formatting issue
< / L R. . . . >
-
Jan 15th, 2021, 12:36 PM
#2
Thread Starter
Member
Re: Draw On Camera Preview screen in VB2010
The drawing code is in - button_info_click()>> help me with it. I do not know much to it
< / L R. . . . >
-
Jan 16th, 2021, 03:31 AM
#3
Thread Starter
Member
Re: Draw On Camera Preview screen in VB2010
ohh come on >> Any one please a little help here ?
< / L R. . . . >
-
Jan 17th, 2021, 10:45 PM
#4
Re: Draw On Camera Preview screen in VB2010
Originally Posted by lokesh R
ohh come on
Maybe that's not the way to make people want to help. Bumping a thread that's a few hours old is seriously frowned on here. If your thread is still on the first page then there's no excuse to be bumping it.
As for the issue, if you had done proper research then you'd know that you don't call CreateGraphics in order to do GDI+ drawing. Some people use that in examples for simplicity but you don't do it in a real application. Do your drawing on the Paint event of the control you want to draw on. In your case, I'd assume that that would be the PictureBox. You can follow the CodeBank link in my signature below and check out some of my GDI+ drawing threads for examples or research the Paint event elsewhere.
Last edited by jmcilhinney; Jan 17th, 2021 at 10:55 PM.
-
Jan 18th, 2021, 03:56 AM
#5
Thread Starter
Member
Re: Draw On Camera Preview screen in VB2010
Originally Posted by jmcilhinney
Maybe that's not the way to make people want to help. Bumping a thread that's a few hours old is seriously frowned on here. If your thread is still on the first page then there's no excuse to be bumping it.
As for the issue, if you had done proper research then you'd know that you don't call CreateGraphics in order to do GDI+ drawing. Some people use that in examples for simplicity but you don't do it in a real application. Do your drawing on the Paint event of the control you want to draw on. In your case, I'd assume that that would be the PictureBox. You can follow the CodeBank link in my signature below and check out some of my GDI+ drawing threads for examples or research the Paint event elsewhere.
I apologies for the comment and the attitude
< / L R. . . . >
-
Jan 18th, 2021, 03:57 AM
#6
Thread Starter
Member
Re: Draw On Camera Preview screen in VB2010
Originally Posted by lokesh R
I apologies for the comment and the attitude
yes, I will try to do so but the problem is these are not just the images to be drawn over picturebox. this is a camera feeding to the picturebox so will that solution work ? i will try and confirm the same
< / L R. . . . >
-
Jan 18th, 2021, 06:14 AM
#7
Re: Draw On Camera Preview screen in VB2010
Originally Posted by lokesh R
will that solution work ?
I don't know, but it has a better chance of working than what you're doing now.
-
Jan 20th, 2021, 03:49 AM
#8
Thread Starter
Member
Re: Draw On Camera Preview screen in VB2010
Originally Posted by jmcilhinney
I don't know, but it has a better chance of working than what you're doing now.
it darws the shpe but it erases as soon as the video comes in
< / L R. . . . >
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|