Results 1 to 3 of 3

Thread: TCPCam - Camera communication library \ ActiveX

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    155

    TCPCam - Camera communication library \ ActiveX

    So here it is, I built a library to create a communication between
    a client side application and host to transfer webcam video stream
    (or actually frames) live based on the TCP protocol.

    I couldn't find any free working library that can transfer live camera stream on the web,
    so I used pieces of ideas to create my own control that can transfer a video stream between a host and a client.

    This library is based on Pino's ICam class to capture the video stream (which has been modified), to find more about this class check out this link:
    http://www.vbforums.com/showthread.php?p=2048466

    Thank you Pino! - go check out his site!

    I built this library for my school project - The nBot.

    This library should work well almost without any noticeable lags on your LAN.

    TCPCam - Camera communication library

    To download this library visit this link (on my website):
    http://byshynet.com/uploads/TCPCam.rar - I was not able to attach the file due to it's size. I also attached some working examples with it.

    This library can be used in 2 ways: as a control (like a button) that you can drag and drop to your project, or just like a normal class.
    I would recommend on using this class as an ActiveX which makes it alot easier. This library uses port 2020 (TCP) by default to create the communication.



    The concept

    The client application sends the frames captured by the camera (connected to the client computer) to the host, which receives the images and updates the control image which creates the "video" stream effect.

    The ActiveX

    Extract the "TCPCam.rar", you should find this directory:
    "TCPCam\TCPCam\TCPCamActivex\TCPCamActivex\bin\Release"

    Enter to your project and do the following:
    1. Open the Toolbox and right click on an empty space in the toolbox.
    2. Select “Choose items...” – a dialog should pop up
    3. Enter the “.Net Framework Components” tab, and click on “Browse...”
    go to the extracted directory path I mentioned earlier and import this file “TCPCamActivex.dll”.
    4. Accept the dialogs.
    5. Now just drag the “TCPClientActivex” control to your form, this is where your camera frames are shown.

    Make it work
    I called the ActiveX in the same name on both client and host applications - "Webcam".

    On the host side
    application we should start listening so we would use this
    methods on the Form_Load event handling method:
    Code:
    Webcam.StartListening()
    When you close the application make sure to close the listening thread:
    Code:
    Webcam.StopListening()
    On the client side application we should first connect the capture source (the camera). On the Form_Load event (or any other event you want) event handling method do the following:
    Code:
    WebCam.Connect(IPAddress)
    WebCam.StartCamera()
    Make sure to connect first and then start the camera!
    When you finished and want to stop the connection do the following:
    Code:
    WebCam.Disconnect()
    WebCam.StopCamera()
    Events

    This ActiveX comes with the following events:
    - OnFrameDraw(ByVal e As System.Windows.Forms.PaintEventArgs)
    - Connected()
    - Disconnected()
    - OnConnection()
    - LostConnection()

    The OnFrameDraw event comes with the e as PaintEventArgs argument, which allows you to draw directly on the frame and can be used on both sides.

    The Connected and Disconnected events are only fired on the client side, every time a connection was succesfully made the control raises the Connected event. Every time a connection ended the control raises the Disconnected event.

    The OnConnection and LostConnection events are only fired on the host side, every time a client connected the OnConnection event is raised. every time a client disconnected, the LostConnection event is raised.

    You can handle this events to monitor your connection status and draw on the camera frames with GDI.

    The TCPCam Class

    Instead of using the TCPCam ActiveX you can use the TCPCam class which can be found on the extracted rar file on this path:
    "TCPCam\TCPCam\TCPCam\bin\Release" just add a reference to your project with the "TCPCam.dll" file. You need a picturebox to display the camera frames on. Declare your camera object before you continue:
    Code:
    Dim Webcam As New TCPCam.Host(Picturebox,Port)
    or as a client:
    Code:
    Dim Webcam As New TCPCam.Client(Picturebox)
    With this class you can use the SendImage method to send images to the host, not just camera frames. I will post more information about the class if anyone will want.
    Last edited by shynet; Sep 25th, 2010 at 05:03 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width