Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

IPcapture vs PImage.get()

$
0
0

Hi,

I'm using IPcapture with multiple MJPEG streams and buffering frames over time in as many circular buffers as there are cameras. The goal is to then display the streams with a delay.

I can currently connect to the cameras and display their original streams without any problem and my circular buffers also seem to be working properly but something strange happens when I try to copy the frames to the buffers. Here is a simplified version of my sketch which displays the problem:

Note: screen resolution is 1920x1080 and the camera stream is 480x300

import ipcapture.*;

IPCapture cam1;

// Circular buffer
PImage[] cam1_buffer;

// These determine the size of the circular buffer and help iterate while writing and reading through them
int nFrames = 60;
int iWrite = 0, iRead = 1;

void setup() {
  fullScreen();

  cam1 = new IPCapture(this, "http://192.168.0.172/axis-cgi/mjpg/video.cgi", "root", "root");
  cam1.start();

  cam1_buffer = new PImage[nFrames];
}

void draw() {
   if (cam1.isAvailable()) {
    cam1.read();
    cam1_buffer[iWrite] = cam1.get();
    if(cam1_buffer[0] != null){
      // The original camera image is displayed correctly at 480x300 in the upper left corner
      image(cam1,0,0);
      // The buffered frame appears under the original one but it is 1920x1080 and contains 4 stretched copies of the original side by side at the top of the image
      image(cam1_buffer[0],0,300);
    }
  }

 // Increment write and read counters
  iWrite++;
  iRead++;

  // Start writing over our buffer every time we reach the end
  if(iRead >= nFrames-1){
    iRead = 0;
  }

  if(iWrite >= nFrames-1){
    iWrite = 0;
  }
}

My understanding is that IPcapture.get(); returns PImages which are the same size as the screen and not the same size as the IPcapture resolution. I haven't found anything in the IPcapture reference on how to force the proper resolution.

Any ideas?

Also is there a way of getting the current stream frame rate? This would allow me to better tune the display delay as the stream frame rate varies over time...

Thanks!


Viewing all articles
Browse latest Browse all 2896

Trending Articles