On the webpage play a remote camera video issues

At present I'm doing a BS project, need to real-time images play a remote camera on the page (LAN), the camera is opposite outside to buy very ordinary camera, how to realize, beg an expert advice. Thank you

Started by Shelley at February 08, 2016 - 2:28 PM

Speaking to the media server ah, is it right? Very troublesome.

Posted by Shelley at February 20, 2016 - 3:27 PM

For you to see this, and I hope to help you .

Posted by Fitch at February 25, 2016 - 3:57 PM

Communication... Long-range. WEBQQ video not?

Posted by natascha at March 02, 2016 - 4:25 PM

Seemed to be looking for a camera provider interface! To achieve!~~

Posted by Ron at March 08, 2016 - 5:14 PM

The Activex control

Posted by Joy at March 11, 2016 - 5:36 PM

There is no specific methods to solve activeX ah, can put a have a look ah thank you

Posted by Shelley at March 26, 2016 - 6:33 PM

This is difficult
I!

Posted by Reg at April 09, 2016 - 7:30 PM

The reply to 2011-04-22 17:23:19 was a moderator to delete

Posted by Wright at April 21, 2016 - 7:58 PM

using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;

namespace CapAvi
{
 /// <summary>
 /// A camera control class
 /// </summary>
 public class CamCap
 {
  private const int WM_USER = 0x400;
  private const int WS_CHILD = 0x40000000;
  private const int WS_VISIBLE = 0x10000000;
  private const int WM_CAP_START = WM_USER;
  private const int WM_CAP_STOP = WM_CAP_START + 68;
  private const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
  private const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
  private const int WM_CAP_SAVEDIB = WM_CAP_START + 25;
  private const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
  private const int WM_CAP_SEQUENCE = WM_CAP_START + 62;
  private const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
  private const int WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;
  private const int WM_CAP_SET_OVERLAY =WM_CAP_START+ 51; 
  private const int WM_CAP_SET_PREVIEW =WM_CAP_START+ 50; 
  private const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
  private const int WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
  private const int WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
  private const int WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
  private const int WM_CAP_SET_SCALE=WM_CAP_START+ 53;
  private const int WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52; 
  private IntPtr hWndC;
  private bool bStat = false;

  private IntPtr mControlPtr;
  private int mWidth;
  private int mHeight;
  private int mLeft;
  private int mTop;

  /// <summary>
  /// Initialize camera
  /// </summary>
  /// <param name="handle">The handle of the control</param>
  /// <param name="left">To display the left margin</param>
  /// <param name="top">It began to show the distance</param>
  /// <param name="width">To display width</param>
  /// <param name="height">To display the length</param>
  public CamCap(IntPtr handle, int left, int top, int width,int height)
   {
    mControlPtr = handle;
    mWidth = width;
    mHeight = height;


    mLeft = left;
    mTop = top;
   }

  [DllImport("avicap32.dll")] 
  private static extern IntPtr capCreateCaptureWindowA(byte[] lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, int nID);
  [DllImport("avicap32.dll")]
  private static extern int capGetVideoFormat(IntPtr hWnd, IntPtr psVideoFormat, int wSize );
  [DllImport("User32.dll")] 
  private static extern bool SendMessage(IntPtr hWnd, int wMsg, int wParam, long lParam);

  /// <summary>
  /// To display the image
  /// </summary>
  public void Start()
   {
    if (bStat)
    return;

    bStat = true;
    byte[] lpszName = new byte[100];

    hWndC = capCreateCaptureWindowA(lpszName,WS_CHILD|WS_VISIBLE ,mLeft,mTop,mWidth,mHeight,mControlPtr,0);

    if (hWndC.ToInt32() != 0)
     {
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
      SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
      SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
      SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
      SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
      SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
     }

    return;

   }

  /// <summary>
  /// Stop showing
  /// </summary>
  public void Stop()
   {
    SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
    bStat = false;
   }

  /// <summary>
  /// Screenshot
  /// </summary>
  /// <param name="path">To save the BMP file path</param>
  public void GrabImage(string path)
   {

    IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
    SendMessage(hWndC,WM_CAP_SAVEDIB,0,hBmp.ToInt64());

   }

  /// <summary>
  /// The video
  /// </summary>
  /// <param name="path">To save the AVI file path</param>
  public void Kinescope(string path)
   {
    IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
    SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0,hBmp.ToInt64());
    SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
   }

  /// <summary>
  /// Stop recording
  /// </summary>
  public void StopKinescope()
   {
    SendMessage(hWndC, WM_CAP_STOP, 0, 0);
   }

 }
}

Posted by Daisy at April 23, 2016 - 8:06 PM

The need to support Activex.
The simple web I don't think so strong

Posted by Charlotte at November 14, 2016 - 10:29 AM

My side is also done with you a similar function, here I call the video equipment maker ActiveX, and then through the server IP, port number, user name and password, the camera can call over there, see the video, but I want to make is the four picture form.

Posted by Guy at November 29, 2016 - 11:18 AM

A class I wrote before you can refer to the reference distance transmission is actually sending pictures
 public class video
    {
        //The 5 argument
        private IntPtr myHand;
        private int myWidth;
        private short myHeight;
        private int myLeft;
        private int myTop;
        //Call avicap32.dll 
        public struct videohdr_tag
        {
            public byte[] lpData;
            public int dwBufferLength;
            public int dwBytesUsed;
            public int dwTimeCaptured;
            public int dwUser;
            public int dwFlags;
            public int[] dwReserved;

        }
        [DllImport("avicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int capCreateCaptureWindowA([MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID);
        [DllImport("avicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool capGetDriverDescriptionA(short wDriver, [MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszName, int cbName, [MarshalAs(UnmanagedType.VBByRefStr)]   ref   string lpszVer, int cbVer);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool DestroyWindow(int hndw);
        [DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)]   object lParam);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
        [DllImport("vfw32.dll")]
        public static extern string capVideoStreamCallback(int hwnd, videohdr_tag videohdr_tag);
        [DllImport("vicap32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        public static extern bool capSetCallbackOnFrame(int hwnd, string s);
        //Custom parameters: 
        private int hHwnd;
        //Constructor
        public video(IntPtr myPtr, int left, int top, int width, short height)
        {
            myHand = myPtr;
            myLeft = left;
            myTop = top;
            myWidth = width;
            myHeight = height;
            //
            // Add TODO: constructor logic here
            //
        }

        //Open the video: 
        public void opVideo()
        {
            int intDevice = 0;
            string refDevice = intDevice.ToString();
            hHwnd = capCreateCaptureWindowA(ref   refDevice, 1342177280, 0, 0, 640, 480, myHand.ToInt32(), 0);
            if (SendMessage(hHwnd, 0x40a, intDevice, 0) > 0)
            {
                SendMessage(this.hHwnd, 0x435, -1, 0);
                SendMessage(this.hHwnd, 0x434, 0x42, 0);
                SendMessage(this.hHwnd, 0x432, -1, 0);
                SetWindowPos(this.hHwnd, 1, 0, 0, myWidth, Convert.ToInt32(myHeight), 6);
            }
            else
            {
                DestroyWindow(this.hHwnd);
            }
        }
        //Stop video
        public void CloVideo()
        {
            SendMessage(this.hHwnd, 0x40b, 0, 0);
            DestroyWindow(this.hHwnd);
        }
        //Capture video
        public Image CatchVideo()
        {
            SendMessage(this.hHwnd, 0x41e, 0, 0);
            IDataObject obj1 = Clipboard.GetDataObject();
            Image getIma = null;
            if (obj1.GetDataPresent(typeof(Bitmap)))
            {
                Image image1 = (Image)obj1.GetData(typeof(Bitmap));
                getIma = image1;
            }
            return getIma;
        }
    }

Posted by Mortimer at December 08, 2016 - 11:27 AM

From form called

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

Namespace camera
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        const short WM_CAP = 1024;
        const int WM_CAP_DRIVER_CONNECT = WM_CAP + 10;
        const int WM_CAP_DRIVER_DISCONNECT = WM_CAP + 11;
        const int WM_CAP_EDIT_COPY = WM_CAP + 30;
        const int WM_CAP_SET_PREVIEW = WM_CAP + 50;
        const int WM_CAP_SET_PREVIEWRATE = WM_CAP + 52;
        const int WM_CAP_SET_SCALE = WM_CAP + 53;
        const int WS_CHILD = 1073741824;
        const int WS_VISIBLE = 268435456;
        const short SWP_NOMOVE = 2;
        const short SWP_NOSIZE = 1;
        const short SWP_NOZORDER = 4;
        const short HWND_BOTTOM = 1;
        int iDevice = 0;
        int hHwnd;
        [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")]
        static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)] 
            object lParam);
        [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowPos")]
        static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
        [System.Runtime.InteropServices.DllImport("user32")]
        static extern bool DestroyWindow(int hndw);
        [System.Runtime.InteropServices.DllImport("avicap32.dll")]
        static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID);
        [System.Runtime.InteropServices.DllImport("avicap32.dll")]
        static extern bool capGetDriverDescriptionA(short wDriver, string lpszName, int cbName, string lpszVer, int cbVer);
        private void OpenPreviewWindow()
        {
            int iHeight = 320;
            int iWidth = 200;
            // 
            //  Open Preview window in picturebox //Open the preview window PictureBox
            // 
            hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0);
            // 
            //  Connect to device is connected to the device
            // 
            if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) == 1)
            {
                // 
                // Set the preview scale set the preview size
                // 
                SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0);
                // 
                // Set the preview rate in milliseconds set the time in milliseconds for the preview rate
                // 
                SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0);
                // 
                // Start previewing the image from the camera to start the preview image from the camera
                // 
                SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0);
                // 
                //  Resize window to fit in PictureBox to adjust the window size to fit in PictureBox
                // 
                SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, (SWP_NOMOVE | SWP_NOZORDER));
            }
            else
            {
                // 
                //  Error connecting to device close window error connecting to device close window
                //   
                DestroyWindow(hHwnd);
            }
        }
        private void ClosePreviewWindow()
        {
            // 
            //  Disconnect from device disconnect the device
            // 
            SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0);
            // 
            //  Close window to close the window
            // 
            DestroyWindow(hHwnd);
        }


        private void button1_Click(object sender, EventArgs e)
        {
            iDevice = int.Parse("4");
            OpenPreviewWindow();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2();
            f.Show();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

Posted by Mortimer at December 14, 2016 - 11:40 AM

Oh ~ wrong I just tried using this line from1 was tested with FROM2 can be directly used
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using YL;


Namespace camera
{
    public partial class Form2 : Form
    {
        video v;
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
           

            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
           
           
            SaveFileDialog sa = new SaveFileDialog();
            sa.Filter = "Preservation(*.bmp)|*.bmp";
            sa.FilterIndex = 2;
            sa.RestoreDirectory = true;
            if (DialogResult.OK == sa.ShowDialog())
            {
                Image im = v.CatchVideo();
                Bitmap bit = new Bitmap(im);
                bit.Save(sa.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            v = new video(pictureBox1.Handle, 250, 250, 429, 310);
            v.opVideo();
          
        }

        private void button3_Click(object sender, EventArgs e)
        {
            v.CloVideo();
        }
    }
}

Posted by Mortimer at December 26, 2016 - 12:02 PM

1, The activeX mode, if the camera with the corresponding API, by this way, the realization of a very simple. If the ordinary camera, this is difficult to achieve. In video compression, transmission etc.... Also consider the performance, very complex.
2, fms(The media server) mode, online this information more. Data

Posted by John at January 04, 2017 - 1:45 PM

The reply to 2011-04-23 17:23:35 was a moderator to delete

Posted by Howard at January 05, 2017 - 12:44 PM

Thank you for help, but the majority of you hair is API CS usage, the C++ engineers have written DLL give us a call, but here I need to call in the b/s system on the webpage, API alone is not enough, I'm looking for a webpage using activeX control

Posted by Shelley at January 10, 2017 - 1:53 PM

To solve the problem of no?
I now also annoyed this problem!

Posted by Lori at January 11, 2017 - 1:03 PM