In your first loop, the output is a concatenation of image data, like copying
multiple PNG files in series onto one file. This is not a valid image
representation. Assuming it is going to a browser, the browser would either
display the first image only (ignoring everything after the PNG end marker),
or display nothing (waiting for the data stream to end), or indicate a corrupt
image.
In your second loop, you can't re-use a PHPlot object. I actually first
noticed this about a year ago, and added it to a list of things to check ("Can
you re-use a PHPlot object? If not, is this a bug?"), but haven't really
looked into it. Some parts of the plot (title, background) are designed to be
done at most once, but I suspect that is only a small part of it, and I'm not
sure if it is worth 'fixing'.
(I was going to refer you to the thread "Marquee style plot", but then I
realized that is you...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, t'is me. (... another rubber tree plant....) I guess: "To the Devs."
Request to be able to $plot->DrawGraph(); without changing anything except
$data. Do something like pop($data), push($data, DrawGraph(). With a
SetDataValues($data); or not.
If one doesn't dream, one can't have dreams come true.....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Devs plural? I'll take that as a compliment, perhaps... It's just me.
Develop, test, document, release, support - etc.)
Currently, using SetDataValues() and DrawGraph() multiple times does work and
is useful, but not for what you want. Combined with SetPrintImage(False), it
is used to put multiple plots on a single image. Note that there is only one
image output, with PrintImage() at the end. Examples: overlaying
plots, side-by-
side plots.
If you can tell me how to send multiple PNG images in response to a single
HTTP request, then we could talk about how to do this in PHPlot. It would be a
pretty neat feature. I don't know how to do it, but that doesn't mean it isn't
possible.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So, you is a Singularity. Didn't know, impressed. Kudos etc etc etc. No
"perhaps".
http://blackforest-
co.com/quake/event.php?start=2012%2F02%2F24+02+&dur=60 is a snapshot. I
have another called "loop.php: event.php now minus 60 second to now > t1.png,
img src=t1,png, refresh=1, which comes pretty close to what I'm trying to do.
You see I bought this seismometer from qcn.stanford.edu ... everybody has
their quirks :-/ and I'm trying to figure out how to make it smooooooooth...
and also reduce cpu. 20 samp/sec. Then of course MuderNature found out and
well it's been the quietest 2 weeks on record. Would it be possible to (see
overlay examp) Jan as a 66x600 image, cached, Feb the same (x+66) Insert Jan,
Feb, Mar... then next year (whatever time period) start with Feb, Mar...
Jan/10. Have a circlular array - fifo - I'll keep playing. If something hits
me (2AM) I'll let you know right away.....
Thanks
Chuck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(I must point out that I didn't write PHPlot. Afan is the author and
copyright holder, and there were other notable contributors before 2007. I was
given control of the project in 2007. The reference manual and test suite are
my own work, and I've rewritten and added much to PHPlot, but I am not the
original creator.)
Back to your interesting challenge. Can you tell me a little about the setup?
Do you have separate systems (client, displaying the graph(s); server,
collecting the data and creating the graphs) or are they the same? If
separate, is this a high-speed LAN or Internet connection? What operating
system/platform? Is the use of a browser to display the data necessary, or
could something else go there?
You get 20 samples per second, and you want to refresh the display how often?
That is a very cool graph, by the way. (And as soon as you turn it off, the
next quake hits, I'm sure.)
Do you know anything about Motion-JPEG (MJPEG)? It's basically a video stream
consisting of a series of JPEG images. It can be streamed over HTTP. Some
browsers have native support for playing it, and there are other programs like
VLC that can. PHPlot can generate individual JPEG images today. See where I'm
going? Pure speculation at this point, but interesting to me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm wondering - instead of 1 png 1000x500, 1000 png's 1x500 then some how
display g0000.png, g0001.png ... g0999.png. And a 1x500 should create very
fast. Now for the mechanics of how to display.....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not interested in trying to see if we can do this with streaming MJPEG over
HTTP? I have no idea if it is possible - only research so far, no actual tests
(except to see how fast PHPlot can make a JPEG image, to see if it is remotely
feasible).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It depends (of course) on many factors besides the processor speed. Image size
is a big factor. JPEG is slower than PNG, and looks uglier with graphs, but
nothing we can do about that. Pie charts are slower than line graphs (area
fills are expensive, it seems).
I am seeing about 0.036 secs for an 800x600 JPEG, 0.025 secs for 640x480 JPEG.
That sort of puts a theoretical upper limit of around 40 frames per second for
"VGA" size, but I think that is way too high anyway and the graph would be a
blur. I am aiming at something more like 10 frames per second as a max.
I have written a simple PHP script (not using PHPlot) that sends a 15 frames
per second JPEG stream (just a line moving around like a clock hand) and
displayed it in my browser. Surprisingly, it works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See: http://en.wikipedia.org/wiki/Frame_rate - see the Computing section. As it indicates "What's your
application?" I think 15 fps the first time around - Well, I'll spring for a
round of beer :-D Would'est thou care to share "simple script"? chucka at
blackforest-co dot com
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We would not be sending "real video" (things moving around all over, bumping
into each other, etc) - more like a moving line chart from a pen recorder. All
I have right now is a "clock" with a second hand that moves around (at the
correct speed, regardless of frame rate). It looks smooth at 15 frames per
second, and not at all bad at 10 fps.
As a JPEG, it has some noise (JPEG compression artifacts). Plots will too. I
found that Firefox 10 (and Mozilla Seamonkey) and VLC Media Player can view
this. Firefox/Seamonkey are better, because you wrap the stream in an HTML
page. I read that Chrome and Safari can view M-JPEG streaming, but I don't
have either to test. I tried MS Internet Explorer 8, and it doesn't work; I
read that a plugin or ActiveX control is needed. I could not get Windows Media
Player, mplayer, or xine to view this, but I don't know much about using them
so it could be my fault.
I had to try it, and was surprised to find that Firefox/Seamonkey can also
view the same streaming format with PNG images instead of JPEG. This is really
neat, but might be an accident. VLC can't view this "streaming PNG".
There is also a bad bug report on Firefox (625012) that says Motion JPEG
viewing flickers badly, but I think that only is a problem at higher frame
rates, like from an IP camera.
Share the script, maybe, it is not really presentable right now... Not up to
PHPlot standards... We'll see. Right now, PHP-5.4 just came out, so I need to
do some testing first. I'll be back here after.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As another thought Some time back - crontab, every min, curl mywebcam >
(time).jpg then once a day cron ran memcoder It used all of the jpgs, 1440,
and output a mov/avi file. Doesn't give you realtime (which is my orig desire)
but if someone wanted to watch, say, how daily temps for the year were - one
phplot per hr > (time).png, then 365 days later make a movie of it....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't stop working on the "looping". But one of the 2 AM Ah-Ha thingies. I
wrote a phplot.php script that reads 10 min of data and creates the graph. As
it ends each $data ='s loop it does an fputs of all of the data in the last
loop. Then when I run the script for the next 10 min segment I do a fscanf of
the date so the formula picks up right where it left off. Then (thanks to you,
lbayuk) each png file, t00.00.png, t00.10.png, ...t23.50.png is naked and I
can display 240 graphs end to end. It's Memorex not live.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It unzips to 2 files: an HTML wrapper and a PHP script. They both go into any
web served directory, then you open the HTML page in a browser (not MSIE
though). You should see 1 minute of 'video' at 10 frames per second. There are
values at the top of the script you can edit to change the parameters. Note
this does not use PHPlot at all.
The timing loop at the very bottom is something like what you would use in a
future PHPlot version that supports this, plus of course the parts where you
update the data. The changes to PHPlot are actually pretty simple, and I am
planning to give it a try.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just DL'ed and ran - nice. At 1 fps it makes a really good second hand. What's
the max? Looks good at 30. When I get a chance I'll examine the code - I'm
running a caucus tonight and gott'a run - now!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, 1 fps is neat and I think there could be real-world applications for a
graph that updates once per second.
There is a frame counter in the lower left of the demo image that also reports
the number of "slipped" frames. A slipped frame is where the sleep-until time
already passed - that is, building and sending a frame took longer than the
frame time. When running the server and browser on the same PC, I saw no
slipped frames through 15 fps, and just 5 slipped frames at 30 fps (out of
1800 total frames). But this is a pretty simple drawing and PHPlot graphs will
take longer.
If I use one PC running Apache and PHP to generate the images, and view them
on another (slower) PC over a 100Mbps LAN, I get better performance. At 30fps,
no frames slipped, and the server was using 72% CPU (on 1 core). At 60fps, it
slipped 100% of the frames, and Apache on the server pinned one core to 100%
utilization. YMMV, of course.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the delay on this. Another change jumped in front, not because it
was more important, but because it was much more straight-forward to document
and test. This 'streaming plots' feature works well, but documenting it took
longer (almost done now), and I haven't got any tests for it yet. But it will
be done soon. There isn't anything in line after this so there is a good
chance of a release soon.
(By testing, I mean scripted testing. Watching 20 minutes of sin() and cos()
at 10 frames per second is fun - for a short time, anyway - but doesn't work
for regression testing.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to do the following:
for ($n=0; $n<100; $n++)
{
$plot = new PHPlot(1000, 500);
...
$plot->DrawGraph();
mod $data...
}
or better yet
for ($n... {
mod $data
$plot->DrawGraph();
}
No mater what I do I get the first graph, n=0, and that's it. Is there any way
to do this? Thanks.
No, not really.
In your first loop, the output is a concatenation of image data, like copying
multiple PNG files in series onto one file. This is not a valid image
representation. Assuming it is going to a browser, the browser would either
display the first image only (ignoring everything after the PNG end marker),
or display nothing (waiting for the data stream to end), or indicate a corrupt
image.
In your second loop, you can't re-use a PHPlot object. I actually first
noticed this about a year ago, and added it to a list of things to check ("Can
you re-use a PHPlot object? If not, is this a bug?"), but haven't really
looked into it. Some parts of the plot (title, background) are designed to be
done at most once, but I suspect that is only a small part of it, and I'm not
sure if it is worth 'fixing'.
(I was going to refer you to the thread "Marquee style plot", but then I
realized that is you...)
Yes, t'is me. (... another rubber tree plant....) I guess: "To the Devs."
Request to be able to $plot->DrawGraph(); without changing anything except
$data. Do something like pop($data), push($data, DrawGraph(). With a
SetDataValues($data); or not.
If one doesn't dream, one can't have dreams come true.....
(Devs plural? I'll take that as a compliment, perhaps... It's just me.
Develop, test, document, release, support - etc.)
Currently, using SetDataValues() and DrawGraph() multiple times does work and
is useful, but not for what you want. Combined with SetPrintImage(False), it
is used to put multiple plots on a single image. Note that there is only one
image output, with PrintImage() at the end. Examples: overlaying
plots, side-by-
side plots.
If you can tell me how to send multiple PNG images in response to a single
HTTP request, then we could talk about how to do this in PHPlot. It would be a
pretty neat feature. I don't know how to do it, but that doesn't mean it isn't
possible.
So, you is a Singularity. Didn't know, impressed. Kudos etc etc etc. No
"perhaps".
http://blackforest-
co.com/quake/event.php?start=2012%2F02%2F24+02+&dur=60 is a snapshot. I
have another called "loop.php: event.php now minus 60 second to now > t1.png,
img src=t1,png, refresh=1, which comes pretty close to what I'm trying to do.
You see I bought this seismometer from qcn.stanford.edu ... everybody has
their quirks :-/ and I'm trying to figure out how to make it smooooooooth...
and also reduce cpu. 20 samp/sec. Then of course MuderNature found out and
well it's been the quietest 2 weeks on record. Would it be possible to (see
overlay examp) Jan as a 66x600 image, cached, Feb the same (x+66) Insert Jan,
Feb, Mar... then next year (whatever time period) start with Feb, Mar...
Jan/10. Have a circlular array - fifo - I'll keep playing. If something hits
me (2AM) I'll let you know right away.....
Thanks
Chuck
(I must point out that I didn't write PHPlot. Afan is the author and
copyright holder, and there were other notable contributors before 2007. I was
given control of the project in 2007. The reference manual and test suite are
my own work, and I've rewritten and added much to PHPlot, but I am not the
original creator.)
Back to your interesting challenge. Can you tell me a little about the setup?
Do you have separate systems (client, displaying the graph(s); server,
collecting the data and creating the graphs) or are they the same? If
separate, is this a high-speed LAN or Internet connection? What operating
system/platform? Is the use of a browser to display the data necessary, or
could something else go there?
You get 20 samples per second, and you want to refresh the display how often?
That is a very cool graph, by the way. (And as soon as you turn it off, the
next quake hits, I'm sure.)
Do you know anything about Motion-JPEG (MJPEG)? It's basically a video stream
consisting of a series of JPEG images. It can be streamed over HTTP. Some
browsers have native support for playing it, and there are other programs like
VLC that can. PHPlot can generate individual JPEG images today. See where I'm
going? Pure speculation at this point, but interesting to me.
All will (should) become clear here -> http://blackforest-
co.com/quake/mar.php
I'm wondering - instead of 1 png 1000x500, 1000 png's 1x500 then some how
display g0000.png, g0001.png ... g0999.png. And a 1x500 should create very
fast. Now for the mechanics of how to display.....
Not interested in trying to see if we can do this with streaming MJPEG over
HTTP? I have no idea if it is possible - only research so far, no actual tests
(except to see how fast PHPlot can make a JPEG image, to see if it is remotely
feasible).
Oh, very interested - like you ... if it is poss. Your mind went mjpeg, my
mind went 1x500. So, how fast can phplot create a jpeg?
It depends (of course) on many factors besides the processor speed. Image size
is a big factor. JPEG is slower than PNG, and looks uglier with graphs, but
nothing we can do about that. Pie charts are slower than line graphs (area
fills are expensive, it seems).
I am seeing about 0.036 secs for an 800x600 JPEG, 0.025 secs for 640x480 JPEG.
That sort of puts a theoretical upper limit of around 40 frames per second for
"VGA" size, but I think that is way too high anyway and the graph would be a
blur. I am aiming at something more like 10 frames per second as a max.
I have written a simple PHP script (not using PHPlot) that sends a 15 frames
per second JPEG stream (just a line moving around like a clock hand) and
displayed it in my browser. Surprisingly, it works.
See: http://en.wikipedia.org/wiki/Frame_rate - see the Computing section. As it indicates "What's your
application?" I think 15 fps the first time around - Well, I'll spring for a
round of beer :-D Would'est thou care to share "simple script"? chucka at
blackforest-co dot com
We would not be sending "real video" (things moving around all over, bumping
into each other, etc) - more like a moving line chart from a pen recorder. All
I have right now is a "clock" with a second hand that moves around (at the
correct speed, regardless of frame rate). It looks smooth at 15 frames per
second, and not at all bad at 10 fps.
As a JPEG, it has some noise (JPEG compression artifacts). Plots will too. I
found that Firefox 10 (and Mozilla Seamonkey) and VLC Media Player can view
this. Firefox/Seamonkey are better, because you wrap the stream in an HTML
page. I read that Chrome and Safari can view M-JPEG streaming, but I don't
have either to test. I tried MS Internet Explorer 8, and it doesn't work; I
read that a plugin or ActiveX control is needed. I could not get Windows Media
Player, mplayer, or xine to view this, but I don't know much about using them
so it could be my fault.
I had to try it, and was surprised to find that Firefox/Seamonkey can also
view the same streaming format with PNG images instead of JPEG. This is really
neat, but might be an accident. VLC can't view this "streaming PNG".
There is also a bad bug report on Firefox (625012) that says Motion JPEG
viewing flickers badly, but I think that only is a problem at higher frame
rates, like from an IP camera.
Share the script, maybe, it is not really presentable right now... Not up to
PHPlot standards... We'll see. Right now, PHP-5.4 just came out, so I need to
do some testing first. I'll be back here after.
As another thought Some time back - crontab, every min, curl mywebcam >
(time).jpg then once a day cron ran memcoder It used all of the jpgs, 1440,
and output a mov/avi file. Doesn't give you realtime (which is my orig desire)
but if someone wanted to watch, say, how daily temps for the year were - one
phplot per hr > (time).png, then 365 days later make a movie of it....
Don't stop working on the "looping". But one of the 2 AM Ah-Ha thingies. I
wrote a phplot.php script that reads 10 min of data and creates the graph. As
it ends each $data ='s loop it does an fputs of all of the data in the last
loop. Then when I run the script for the next 10 min segment I do a fscanf of
the date so the formula picks up right where it left off. Then (thanks to you,
lbayuk) each png file, t00.00.png, t00.10.png, ...t23.50.png is naked and I
can display 240 graphs end to end. It's Memorex not live.
I put my Streaming Motion-JPEG demo here temporarily in case you (or anyone
else) wants to try it.
It unzips to 2 files: an HTML wrapper and a PHP script. They both go into any
web served directory, then you open the HTML page in a browser (not MSIE
though). You should see 1 minute of 'video' at 10 frames per second. There are
values at the top of the script you can edit to change the parameters. Note
this does not use PHPlot at all.
The timing loop at the very bottom is something like what you would use in a
future PHPlot version that supports this, plus of course the parts where you
update the data. The changes to PHPlot are actually pretty simple, and I am
planning to give it a try.
Just DL'ed and ran - nice. At 1 fps it makes a really good second hand. What's
the max? Looks good at 30. When I get a chance I'll examine the code - I'm
running a caucus tonight and gott'a run - now!
Yes, 1 fps is neat and I think there could be real-world applications for a
graph that updates once per second.
There is a frame counter in the lower left of the demo image that also reports
the number of "slipped" frames. A slipped frame is where the sleep-until time
already passed - that is, building and sending a frame took longer than the
frame time. When running the server and browser on the same PC, I saw no
slipped frames through 15 fps, and just 5 slipped frames at 30 fps (out of
1800 total frames). But this is a pretty simple drawing and PHPlot graphs will
take longer.
If I use one PC running Apache and PHP to generate the images, and view them
on another (slower) PC over a 100Mbps LAN, I get better performance. At 30fps,
no frames slipped, and the server was using 72% CPU (on 1 core). At 60fps, it
slipped 100% of the frames, and Apache on the server pinned one core to 100%
utilization. YMMV, of course.
I wrote a feature request to make it official. (I do have it working
in PHPlot... very neat, even though I am only plotting random numbers.)
Share code? Please.....
Thank you.
Sorry for the delay on this. Another change jumped in front, not because it
was more important, but because it was much more straight-forward to document
and test. This 'streaming plots' feature works well, but documenting it took
longer (almost done now), and I haven't got any tests for it yet. But it will
be done soon. There isn't anything in line after this so there is a good
chance of a release soon.
(By testing, I mean scripted testing. Watching 20 minutes of sin() and cos()
at 10 frames per second is fun - for a short time, anyway - but doesn't work
for regression testing.)
PHPlot-5.8.0 was just released, and includes this capability, with
documentation in the reference manual.