dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Draw Image From File on Video

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2019
    Posts
    53

    Resolved [RESOLVED] Draw Image From File on Video

    Hi Guys,

    I'm trying to overlay an image on a video stream. How can i resize and position my image on the video? So far, here is my code:

    Code:
    Private Sub CAPTURE(ByVal sender As Object, ByVal eventArgs As NewFrameEventArgs)
    
            
                                If ButtonVIDEO.BackColor = Color.Black Then 'IF YOU ARE NOT RECORDING ......
                                    BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PUT THE DATA IN THE BITMAP
                                    PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PRESENTS THEM AT THE PICTURE BOX
                                    
                                    Dim imagePath As String = "C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg"
                                    PictureBox1.Image = Image.FromFile(imagePath)
    
                                Else 'IF YOU ARE RECORDING ...
                                    BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap)     'PUT THE DATA IN THE BITMAP
                                    PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap)  'PRESENTS THEM AT THE PICTURE BOX
                                    ESCRITOR.WriteVideoFrame(PictureBox1.Image)  'KEEP THEM IN THE MEMORY
    
                                End If
    
                               
        End Sub
    Last edited by joko markono; Jan 22nd, 2020 at 02:57 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Sep 2019
    Posts
    53

    Re: Draw Image From File on Video

    I answer my own question:

    Code:
    Private Sub CAPTURE(ByVal sender As Object, ByVal eventArgs As NewFrameEventArgs)
    
           
    
                                If ButtonVIDEO.BackColor = Color.Black Then 'IF YOU ARE NOT RECORDING ......
                                    BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PUT THE DATA IN THE BITMAP
                                    PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap) 'PRESENTS THEM AT THE PICTURE BOX
                                    Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
                                    g.DrawString(datareceive_label.Text, New Font("courier new", 10), Brushes.White, New Rectangle(10, 10, 1000, 500))
                                    Dim h As Graphics = Graphics.FromImage(PictureBox1.Image)
                                    h.DrawString(datareceive_label2.Text, New Font("courier new", 10), Brushes.White, New Rectangle(10, 22, 1000, 500))
    
                                   
                                    'Eg. address: C:\Users\jaimy\Desktop\Visual Studio\Advance HMI\OTHER IMAGE\WS LOGO.png
    
                                    If ConfirmButton.BackColor = Color.LimeGreen Then
                                        Dim x As Integer = 100
                                        Dim y As Integer = 100
                                        Dim width As Integer = 450
                                        Dim height As Integer = 150
                                        Dim imagePath As Image = Image.FromFile(PhotoAddressRichTextBox.Text)
                                        Dim i As Graphics = Graphics.FromImage(PictureBox1.Image)
                                        i.DrawImage(imagePath, x, y, width, height)
                                    End If
    
                                Else 'IF YOU ARE RECORDING ...
                                        BMP = DirectCast(eventArgs.Frame.Clone(), Bitmap)     'PUT THE DATA IN THE BITMAP
                                    PictureBox1.Image = DirectCast(eventArgs.Frame.Clone(), Bitmap)  'PRESENTS THEM AT THE PICTURE BOX
                                    Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
                                    g.DrawString(datareceive_label.Text, New Font("courier new", 10), Brushes.White, New Rectangle(10, 10, 1000, 500))
                                    Dim h As Graphics = Graphics.FromImage(PictureBox1.Image)
                                    h.DrawString(datareceive_label2.Text, New Font("courier new", 10), Brushes.White, New Rectangle(10, 22, 1000, 500))
    
                                    ESCRITOR.WriteVideoFrame(PictureBox1.Image)  'KEEP THEM IN THE MEMORY
    
                                End If
    
                              
    
        End Sub
    Last edited by joko markono; Jan 23rd, 2020 at 08:09 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width