Page 1 of 1

JPEGStream IP Camera Help

PostPosted: Sun Jul 07, 2019 9:41 pm
by wijic#
Hello everyone,

I am having some trouble trying to use JPEGStream for an IP camera. It is not possible to use MJPEGStream because it is H.264. But it has a snapshot URL for a JPEG image. Is my code below correct? I keep getting "Object is currently in use elsewhere." I have looked for examples online but they are all for MJPEGStream, it is hard to find one for JPEGStream. I apologise in advance for my noob/naive questions.

Thank you


Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AForge.Video;


namespace IP_camera
{
    public partial class Form1 : Form
    {
        JPEGStream stream;
        public Form1()
        {
           
            InitializeComponent();
            stream = new JPEGStream("http://192.168.0.4/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=ddlkfjdkfjddfjdk&user=admin&password=");
            stream.NewFrame += new NewFrameEventHandler(video_NewFrame);
        }

        private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap bitmap = eventArgs.Frame;
            pictureBox1.Image = bitmap;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void BtnStart_Click(object sender, EventArgs e)
        {
            stream.Start();
        }

        private void BtnStop_Click(object sender, EventArgs e)
        {
            stream.Stop();
        }
    }
}



Re: JPEGStream IP Camera Help

PostPosted: Mon Jul 08, 2019 7:45 am
by andrew.kirillov
Hello,

Try clonning the image you set to picture box.

There is no difference in working with JPEGs or MJPEG stream - all same. Only the init part is different, where you create different object.

Re: JPEGStream IP Camera Help

PostPosted: Thu Aug 01, 2019 1:19 pm
by wijic#
Hi Andrew,


Thank you very much. It worked like a charm :)