Extremely slow turnaround on snapshot requests

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
Post Reply
AlanG
Posts: 2
Joined: Thu Aug 25, 2016 9:04 am

Extremely slow turnaround on snapshot requests

Post by AlanG »

I am trying to write an Android app which repetitively obtains snapshots from my IP2M-841B and does some computer vision processing on them. I'm trying to get 5 or 6 1280X720 snapshots processed per second on a Galaxy S5 phone. Edited to show its essentials, the loop I'm running in the processing thread looks like this:

Code: Select all


    while((robotBitmapURL != null) && (Thread.currentThread() == ipCameraSnapshotGrabber)) {
try {

//robotBitmapURL has the form "http://UID:pwd@ipaddress:80/cgi-bin/snapshot.cgi?"
connection = (HttpURLConnection)robotBitmapURL.openConnection();

connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Basic " + authStringEncoded);
connection.setDoInput(true);

connection.connect();

snapShotStream = connection.getInputStream();

synchronized (AmcrestIPCamera.this) {
snapShot[latestSnapshot] = BitmapFactory.decodeStream(snapShotStream);
latestSnapshot = 1 - latestSnapshot;//Flip the double buffer index, to point to the next buffer
}

snapShotStream.close();

connection.disconnect();

//Insert the proper bitmap into the "robot's eye view" display, i.e., the bitmap pointed to
// BEFORE the double buffer index was flipped! (Scheduled on the UI Thread)
deliverThenDrawBitmap(snapShot[1 - latestSnapshot]);

} catch (Exception e) {
//------------------------------
}
}
In this loop, ALL of the processing steps EXCEPT the "getInputStream" require a TOTAL time of typically 100 to 130 milliseconds, which is quite satisfactory for my purposes. However, the "getInputStream" by itself requires between 1.5 and 2.8 SECONDS. This means that my app typically needs 3 seconds to update what appears on the phone's screen. The "snapshot interval" specified in the camera's Configuration Utility is always set to 1 second, although I expect that this is irrelevant to the operation of my app (or it SHOULD be!).

Why is this happening? And how can I work around it?
AlanG
Posts: 2
Joined: Thu Aug 25, 2016 9:04 am

Re: Extremely slow turnaround on snapshot requests

Post by AlanG »

TheUberOverLord wrote:Snapshot refresh speed can be increased/decreased by the IP Cameras video settings. You can play around with them to get better snapshot turnaround which may or may not impact the IP Cameras image quality.

Working live automatic refreshed snapshot example: https://amcrest.com/forum/post5198.html#p5198

Here are example video settings that support pulling 1 snapshot per second.

Image

The Amcrest IP Cameras currently don't support pulling over this rate. This may change in the future.

I have made a request to address this issue and support higher snapshots per second. I will post back here if that request has been addressed.

Don
Thanks, Don, for a prompt and helpful response!

As it turns out, I have already done some playing around with video settings, trying to get that "getInputStream" time down to a number in the millisecond range. Because of my vision processing requirements, I have chosen 1280X720 video, and I can decode the JPEG snapshot stream into a 1280X720 bitmap in about 90-120 ms,, once the "get" has finally finished!

I'm having a problem trying look at the examples you've sent. The Amcrest Forum keeps telling me "No route found" when I try to access "post5198" . And the link to the ".png" image of the example video settings does not come up as a "live" link, when I click on it.

Is there any other way that you can re-send the 5198 HTML or the PNG image?

And is there any way that I can add my voice to your request to Amcrest for improvements in their code? Except for snapshot turnaround time, the camera seems otherwise satisfactory for what I want to do with it as the "eye" for a robot. (So far, when it comes to face detection in a given snapshot, night vision detection is performing even better than daylight detection!)

Alan
User avatar
TheUberOverLord
Posts: 32
Joined: Sun Jul 31, 2016 5:14 pm

Re: Extremely slow turnaround on snapshot requests

Post by TheUberOverLord »

Snapshot refresh speed can be increased/decreased by the IP Cameras video settings. You can play around with them to get better snapshot turnaround which may or may not impact the IP Cameras image quality.

Working live automatic refreshed snapshot example:

general-discussion-f6/generic-browser-a ... html#p5198

Here are example video settings that support pulling 1 snapshot per second.

Image

The Amcrest IP Cameras currently don't support pulling over this rate. This may change in the future.

I have made a request to address this issue and support higher snapshots per second. I will post back here if that request has been addressed.

Don
Post Reply