PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
I need help with 1 thing...-VBForums
Results 1 to 19 of 19

Thread: I need help with 1 thing...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Question I need help with 1 thing...

    I am working on a program to capture jpg image form ip cam. I have a HikVision camera and the snapshot url is http://ipaddress/streaming/channels/1/picture/ my issue is it never actually gives a file name like picture.jpg, it only displays the snapshot in the browser window. I have tried everything that I can think of but I cannot get the image into a picturebox. I can get to it with the web browser control but then I have no way of saving the image or setting it to the picture and save it from there.

    I need someone to show me how to grab the image and set it to a picturebox or be able to save it from a webbrowser control or if there is a better way then I am all ears. I have been working on this all week and can't get it.

    Please Help!!

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    Even if someone could tell me how to copy the displayed image from a webbrowser control and paste it into the picturebox control that would work also. Then i could say the picturebox image.

  3. #3
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,652

    Re: I need help with 1 thing...

    Quote Originally Posted by smcs View Post
    Even if someone could tell me how to copy the displayed image from a webbrowser control and paste it into the picturebox control that would work also. Then i could say the picturebox image.
    OK,
    Question 1: What do you want to do with the image once you have it?

    Question 2: Capture it and use it exactly as is, or work on it with an image tool?

    Poppa.
    Along with the sunshine there has to be a little rain sometime.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    All I want to do is save it after I get it into the picturebox. Thats it. I have a Foscam now and it works fine because Foscam provides a filename so I can retrieve that like: http://url/snapshot/pic.jpg but HikVision does not provide that .jpg info. The HikVision snapshot appears in the browser window and I have no issues getting it in the Browsercontrol but I cant get it out of there so it does me no good. I even tried copy and paste by code and that didnt work but if I would use the mouse to copy and then past to picturebox by code it would work. I ran out of ideas..

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    Poppa, can you ehlp me with this issue? Or can anyone help me figure out how to save the image?

  6. #6
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,191

    Re: I need help with 1 thing...

    Patience... not everyone lives on this site full-time.

    Worst case, you can look into the Graphics.CopyFromScreen method.

  7. #7
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Lightbulb Re: I need help with 1 thing...

    Try running this code after you have loaded the page with the image and see if it will populate any items into a listbox.
    vb.net Code:
    1. 'Gets all images urls from a webpage to a listbox1
    2.     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    3.         Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
    4.         For Each webpageelement As HtmlElement In allelements
    5.             Dim str As String = webpageelement.GetAttribute("src")
    6.             If str.Length > 3 And str.Contains(".png") Or str.Contains(".gif") Or str.Contains(".jpg") Then
    7.                 ListBox1.Items.Add(str)
    8.             End If
    9.         Next
    10.     End Sub

    If that does provide you with the url of the image your needing then you can get it to a picturebox like this.
    vb.net Code:
    1. PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(ListBox1.Items.Item(0).ToString)))
    Last edited by Vexslasher; Sep 16th, 2016 at 03:19 PM.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    I tried your code and it did not put anything in the listbox but I did get the picture in the web browser control like always.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    I ran the code again with a message box and it is blank, blank, and then pops up the url that I give in the beginning post
    I am not sure how it actually gets the picture with no filename. I can right click in the webbrowser control, copy and then click a button and paste it into the picturebox, but I can't get that to work without using the mouse.

  10. #10
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Re: I need help with 1 thing...

    Quote Originally Posted by smcs View Post
    I tried your code and it did not put anything in the listbox but I did get the picture in the web browser control like always.
    Sometimes websites don't use an extension for their images in these cases the browser just checks the MIME type and it will know how to display it from that information. However if this is the case there still should be a filename that could be used. I can't really look at the source code for that link you provided in your first post but if you look through the source code there should be a name somewhere for that image that could be used.

    It might would show up in the listbox if you removed this line "If str.Length > 3 And str.Contains(".png") Or str.Contains(".gif") Or str.Contains(".jpg") Then" but it would also show up a lot of other random stuff.

    The fastest way I know of to get the names of an image is with Firefox you can then right click an image and click "view image info" that should provide the name there. If it doesn't show up there then there is another way you can get it with Firefox by right clicking the image and then clicking "inspect element".
    Last edited by Vexslasher; Sep 16th, 2016 at 04:51 PM.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    Yep, if you pm me I will give you the actual link so you can see it.

  12. #12
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Re: I need help with 1 thing...

    I'm guessing that the name will be located in the source with something like this.
    <img src="getimg.php?i=TheImageName&f=J"

    If you want to pm me that link I could take a look at it for you. I pm'd you, you can check it here.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    I sent you the link and just so you know I tried everything you described so far with Firefox. I have not come up with any solution. The only control that I can get to bring in the image is a webbrowser control but when I do that I can't do anything with the image. I really hope you can find something that I overlooked of just couldn't find.

  14. #14
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,652

    Re: I need help with 1 thing...

    Quote Originally Posted by smcs View Post
    Poppa, can you ehlp me with this issue? Or can anyone help me figure out how to save the image?
    Sorry for the delay, SWMBO has to come first.

    OK, here's something to think about:

    Start a new project,
    Make the Form1 a medium size, (say) 600,680
    Add 3 Buttons, along the bottom edge. I put 'em in the order (from left) 2, 3, 1.
    Add a PictureBox at the top. Make it square (say) 580,580
    Set the PictureBox SizeMode to Zoom
    Add this code: -
    (Copy n Paste)

    NOTE:
    You will need to set the filepaths to an existing folder, and to an existing image file. And give the saved file a name which doesn't clash with anything, I've not built-in any safeguards!

    Code:
    Public Class Form1
    
        Private Sub Form1_Load() Handles MyBase.Load
            Button1.Text = "EXIT"
            Button2.Text = "Load"
            Button3.Text = "Save"
        End Sub
    
        Private Sub Button1_Click() Handles Button1.Click
            Application.Exit()
        End Sub
    
        Private Sub Button2_Click() Handles Button2.Click
            Dim z As String = "C:\temp\Snowdrop.jpg"
    
            If Not My.Computer.FileSystem.FileExists(z) Then
                Application.Exit()
            Else
                Me.PictureBox1.ImageLocation = z
            End If
            Me.PictureBox1.Refresh()
        End Sub
    
        Private Sub Button3_Click() Handles Button3.Click
            Dim z As String = "C:\temp\tempPic.jpg"
            PictureBox1.Image.Save(z, System.Drawing.Imaging.ImageFormat.Jpeg)
        End Sub
    
    End Class
    You should find the image of the PictureBox under the given name in the given folder, the picture will be square, if the loaded image is not, it'll leave blank edges either top n bottom or at both sides depending on the orientation of the original image.
    With this in mind, you may wish to set the BackColor of the PictureBox to something other than white.


    Poppa.

    (SWMBO: She Who Must Be Obeyed)

    Pop.
    Along with the sunshine there has to be a little rain sometime.

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Sep 2016
    Posts
    18

    Re: I need help with 1 thing...

    Poppa, thank you for the response but that is not the issue. I know how to load a picture into the picturebox but the camera does not provide a filename so there is nothing to load. The webbrowser control will load the picture but there is no filename at all.

  16. #16
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Resolved Re: I need help with 1 thing...

    Here is the solution, I tested it and it works just put in the proper USERNAME, PASSWORD and the url in the button click event with the ip address.
    vb.net Code:
    1. Function GetImage(ByVal url As String) As Image
    2.         Using W As New System.Net.WebClient
    3.             W.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
    4.             Using S As New IO.MemoryStream(W.DownloadData(url))
    5.                 Return CType(Image.FromStream(S).Clone, Image)
    6.             End Using
    7.         End Using
    8.     End Function
    9.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    10.         PictureBox1.Image = GetImage("http://ipaddress/streaming/channels/1/picture/")
    11.     End Sub
    The above code will put the image from that url into picturebox1 when you press button1.

    He pm'd me this was what he needed here is his reply.
    Quote Originally Posted by smcs
    I am very impressed!! I tried your code and it works flawlessly!! I thank you so much!!
    Last edited by Vexslasher; Sep 19th, 2016 at 03:24 PM.

  17. #17

    Re: I need help with 1 thing...

    did you try to convert the images in any other format???

  18. #18
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,133

    Re: I need help with 1 thing...

    I think the code has already been shared to create screenshots but, you can make a standard screenshot program and display the file name on the title area (where says like form1)
    it would be something like this
    Code:
     me.text = filename
    to display the path (if I understood your question right.)
    Disclaimer: When code is given for example - it is merely a example.
    See my browser project BeffsBrowser
    Try my new Browser project LightBrowse "A Browser and not much else" Screen Capture with Imgur API


    Unless said otherwise (e.g. From one of my projects thus, those are mostly licensed under MIT) - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  19. #19
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Skunthorpe, North Lincolnshire, England.
    Posts
    1,652

    Re: I need help with 1 thing...

    Quote Originally Posted by smcs View Post
    Poppa, thank you for the response but that is not the issue. I know how to load a picture into the picturebox but the camera does not provide a filename so there is nothing to load. The webbrowser control will load the picture but there is no filename at all.
    You seem to've missed my point. Did you even read this subroutine? You obviously didn't try the project. So I wasted my time staying up until gone 02.00 AM just to be sure you has a solution in the morning!

    Code:
        Private Sub Button3_Click() Handles Button3.Click
            Dim z As String = "C:\temp\tempPic.jpg"
            PictureBox1.Image.Save(z, System.Drawing.Imaging.ImageFormat.Jpeg)
        End Sub
    If you look in this subroutine you should notice that it has 'Invented' a name for the image.
    Also, I deliberately used a string variable to show that you can pre-determine what that name might be.
    Here is a suggested example:

    Code:
    Public Class Form1
    
        Dim FilePath As String ' Place this code Before the first Sub.
    
        Private Sub Form1_Load() Handles MyBase.Load
            FilePath = Now.ToString
    
            FilePath = "C:/Project/Session " & FilePath.Substring(0, 14)
            If Not My.Computer.FileSystem.DirectoryExists(FilePath) Then
                MkDir(FilePath)
            Else
                Application.Exit()   'Unlikely! but just try again in a minute.
            End If
        End Sub
    
        Private Sub SomeOther()
        Dim SequenceNum As Int32 = 0
    
            'Maybe you have some form of loop to load your images ?
    
            '(Say)
            For i = 1 To Whatever
                SequenceNum += 1
            'Your code in here, load your picture...
    
            Me.PictureBox1.Refresh()
            SaveImage(SequenceNum)
            Next
        End Sub
    
        Private Sub SaveImage(ByVal Num As Int32)
            Dim z As String = FilePath & "\Image_" & Num.ToString & ".jpg"
            PictureBox1.Image.Save(z, System.Drawing.Imaging.ImageFormat.Jpeg)
        End Sub
    Poppa.
    Along with the sunshine there has to be a little rain sometime.

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