1

I am working on a requirement to display the luma value of raw YUV image(1280 x 720) as graph. That is, I am separating the Y data and displaying it in the form of graph, in which x axis is the width and the y axis is the respective Y value.

// Code

            int count = 0;
            int byteValue = 0;
            for ( y = 0; y < height; y++) {
                for (x = 0; x < width; x++) {
                    byteValue = pPictureIn[count++] & 0xff;
                        series.addLast(x, byteValue);
                }
            }

            final PlotStatistics stats = new PlotStatistics(10, false);

            plot.addListener(stats);

            redrawer = new Redrawer(Arrays.asList(new Plot[]{plot}),
            1, false);

            format = new LineAndPointFormatter(this, R.xml.formatter);

            plot.addSeries(series, format);
            redrawer.start();

I am using AndroidPlot to plot the graph. And I am adding all the points to the series. Here my problem is, if I try to render the points, My app gets freezed. And I am using the render mode as USE_BACKGROUND_THREAD.

Someone please help me to render the points at one shot without any freeze. Thanks in advance

Vinoth ios
  • 255
  • 1
  • 3
  • 12
  • 1
    On what thread are you going through every pixel in your image? – Morrison Chang Jan 10 '17 at 15:53
  • I am going through the pixels in a Async task and I started to render on the post execute method. @Morrison Chang – Vinoth ios Jan 10 '17 at 15:55
  • If I give less points its rendering properly. Otherwise the app is freezing. @Morrison Chang – Vinoth ios Jan 10 '17 at 15:57
  • If you are going through every pixel in Java (and waiting for it) - try RenderScript - http://stackoverflow.com/documentation/android/5214/renderscript/18462/getting-started#t=201701101558355622906 – Morrison Chang Jan 10 '17 at 16:00
  • So, can I use this renderScript for rendering the graph?? Because going through all the pixels did not cause any problem @Morrison Chang – Vinoth ios Jan 10 '17 at 16:04
  • Verify that it is AndroidPlot that is the performance bottleneck, at which point either use fewer points, switch libraries to one which will render faster, make improvements to AndroidPlot (I think its open-source), or create your own fast plotting library. – Morrison Chang Jan 10 '17 at 16:48
  • Your trying to make a plot with 1280x720 points on it. as you don't have a display that is 1280x720 wide your not going to be able to see the data anyway. – Ifor Jan 10 '17 at 17:06

1 Answers1

0

Im going to guess that you're using SimpleXYSeries, which is not optimized for efficiency or speed; the calls to addLast become extremely expensive as the number of points increase. Using a fixed memory XYSeries implementation will provide far better performance. If your image data is dynamic (coming from a camera or some other image stream) then a ring buffer might be a good design to consider...I'd suggest taking a look at FixedSizeEditableXYSeries in particular.

Additionally, you might consider sampling your data to reduce the size using SampledXYSeries.

The Advanced XY Series Types doc has more details about the pros and cons of the above mentioned classes and a few others.

Nick
  • 8,181
  • 4
  • 38
  • 63
  • I preferred the opengl rendering for this issue and I am done. But still, I will take a look at it as I am using the XYSeries for other purpose.. Thank you nick@Nick – Vinoth ios Jan 26 '17 at 11:07