AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

JPEGStream IP Camera Help

The forum is to discuss topics related to different areas of image processing and computer vision.

JPEGStream IP Camera Help

Postby wijic# » Sun Jul 07, 2019 9:41 pm

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();
        }
    }
}


wijic#
 
Posts: 5
Joined: Sun Jul 07, 2019 9:34 pm

Re: JPEGStream IP Camera Help

Postby andrew.kirillov » Mon Jul 08, 2019 7:45 am

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.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3446
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: JPEGStream IP Camera Help

Postby wijic# » Thu Aug 01, 2019 1:19 pm

Hi Andrew,


Thank you very much. It worked like a charm :)
wijic#
 
Posts: 5
Joined: Sun Jul 07, 2019 9:34 pm




Return to Image Processing and Computer Vision