I am new to android and trying to learn creation or plotting of graphs in android. I've come across 2 libraries:
GraphView
AndroidPlot.
My intent would be to receive some sound file and plot it on a graph. So, for this purpose which library would be better. Also I wanna know, where I can see the complete implementation or definitions of these libraries i.e. the structure and code for the API's used in the above libraries.
Also I have tried some sample codes available on net. But I'm looking for a more sophiticated code which I could develop on eclipse ADT and hence can learn something out of it.
My intent would be to receive some sound file and plot it on a graph
Neither library does this by default. The libraries are used to plot a graph given a set of data points. Getting the data points from the sound file is up to you.
So, for this purpose which library would be better.
Either library should be fine once you get the data points.
Also I wanna know, where I can see the complete implementation or definitions of these libraries i.e. the structure and code for the API's used in the above libraries.
Check out the sources for GraphView and AndroidPlot.
I have used Achartengine some times and it works great. I modified it without difficulties.
If You are drawing simple Line Graph using canvas to draw the graph.
Use AndroidPlot. This code draw the content of Vector(in this case filled of zeros). You only have to pass the info of the wav file to the vector. And you can check this thread for the reading issue.
Android: Reading wav file and displaying its values
plot = (XYPlot) findViewById(R.id.Grafica);
plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 0.5);
plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1);
plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.rgb(255, 255, 255));
plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.rgb(255, 255, 255));
plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.rgb(255, 255, 255));
plot.getGraphWidget().setDomainLabelPaint(null);
plot.getGraphWidget().setRangeLabelPaint(null);
plot.getGraphWidget().setDomainOriginLabelPaint(null);
plot.getGraphWidget().setRangeOriginLabelPaint(null);
plot.setBorderStyle(BorderStyle.NONE, null, null);
plot.getLayoutManager().remove(plot.getLegendWidget());
plot.getLayoutManager().remove(plot.getDomainLabelWidget());
plot.getLayoutManager().remove(plot.getRangeLabelWidget());
plot.getLayoutManager().remove(plot.getTitleWidget());
//plot.getBackgroundPaint().setColor(Color.WHITE);
//plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
plot.setRangeBoundaries(-25, 25, BoundaryMode.FIXED);// check that, these //boundaries wasn't for audio files
InicializarLasVariables();
for(int i=0; i<min/11;i++){
DatoY=0;
Vector.add(DatoY);
}
XYSeries series = new SimpleXYSeries(Vector, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,"");
LineAndPointFormatter seriesFormat = new LineAndPointFormatter(Color.rgb(0, 0, 0), 0x000000, 0x000000, null);
plot.clear();
plot.addSeries(series, seriesFormat);
Related
I need to compare two images to find the equality . I have searched a lot about AR and openCV. Already gone through compare two images in android and Tried OpenCV samples too . With OPENCV only ORB is free to use and it will compare images in GrayScale and thats not what i need.
P.S:- The need is i have 4 images of a object in my app. SO if user scan a real object using camera then i need to figure out the object in this scanned image does match any of the object in those 4 images or not. I know it way off-topic and also too broad as per SO standard but I really need help on this.
EDIT:- After trying some algos from github i stumble upon on This project . And the results are quite satisfying . I already have tested it with several templates . I am stuck here with one problem . I need to show to user whether the object found or not(a boolean) . How can i determine this if object is detected correctly or not ?
Putting some final step code below.
Point point1=new Point(sceneCorners.get(0,0));
Point point2=new Point(sceneCorners.get(1,0));
Point point3=new Point(sceneCorners.get(2,0));
Point point4=new Point(sceneCorners.get(3,0));
Imgproc.line(rgb, point1, point2, new Scalar(0, 255, 0), 4);
Imgproc.line(rgb, point2, point3, new Scalar(0, 255, 0), 4);
Imgproc.line(rgb, point3, point4, new Scalar(0, 255, 0), 4);
Imgproc.line(rgb, point4,point1, new Scalar(0, 255, 0), 4);
the 2 points are found on each detection . How can i determine that it detected the object or not ? Some things i already tried :
1. Check for rectangle formed with those points:- This can fail .
What is the recommended approach for solving this problem. I have searched a lot most of every sample on github but not found a solution for this .
Please let me know which approach should i follow ?
I have a requirement like this. Here is my home class snapshot.
It contains several shop shape. And for that I have used this code :
ArrayList<Point> points2 = new ArrayList<Point>();
points2.add(vertex.Get(20, 0));
points2.add(vertex.Get(44, 0));
points2.add(vertex.Get(44, 25));
points2.add(vertex.Get(20, 25));
Polygon view1 = new Polygon(context, points2, android.R.color.holo_orange_dark, R.color.background_light, floor != 0);
view1.setId(0);
views.add(view1);
addView(view1);
This is for static number of shapes.Now requirement is such that number of shapes will be dynamic.and for that i don't need to use same code as above.Client has told to implement Straight Skeleton Algorithm.
I googled about it and found some help for same algorithm implementation in core java.
Java library for creating straight skeleton?
This issue explains in java.I tried it out,that is totaly in core java.I need to implement it on android.and Never worked on such issue before.Need some help if some one have already implemented it on android.
Thanks
You should try this:
https://code.google.com/p/campskeleton/
From this answer:
Java library for creating straight skeleton?
I want to implement indoor navigation through image recognition using Vuforia tool which works collaboratively with Android SDK.
I have collected the images that I want to use and now I have succesfully replaced the default picture of ImageTargets appication so as to add my own pictures.
My problem is the step further, since when this application recognizes a museum exhibit diplays a teapot.I want to replace this teapot with arrows that will help museum users to navigate into the museum.
How can I do it?There is an article to the official website of Vuforia which partially clarifies what must have happened but it's far from comprehensive(https://developer.vuforia.com/resources/dev-guide/replacing-teapot).
Any help might be totally crucial for me
Thank you in advance
The first step is to create your arrow models in a program such as Blender or Autodesk Maya and export it as a Wavefront OBJ file. You may have to tweak some plugins/settings in your chosen modelling software to enable that option.
Then you need to convert that .obj file to a C/C++ include file (.h) to work with the native code in ImageTargets.cpp. There is a convenient Perl script that you can download to make this process easier - OBJ2OPENGL.
Then it is a matter of importing your new model in ImageTargets.cpp, e.g. #import "arrow.h" then replace the code to draw the teapot with the following:
// set input data to arrays
glVertexPointer(3, GL_FLOAT, 0, arrowVerts);
glNormalPointer(GL_FLOAT, 0, arrowNormals);
glTexCoordPointer(2, GL_FLOAT, 0, arrowTexCoords);
// draw data
glDrawArrays(GL_TRIANGLES, 0, arrowNumVerts);
Don't forget to rebuild the project using ndk-build when you're finished.
I have written a radar weather app using osmdroid for map tiles, and manually overlaying NOAA ridge radar data. Everything Is working great except that the radar images are unprojected, while the openstreetmap tiles are in transverse Mercator projection. The weather lies within the bounds it should but the data is distorted.
I see three ways to fix this (in order of preference) but am having trouble with all three:
1) find a source of radar data already projected in mercator - hours of Googling later, I've found nothing
2) programmatically reproject the images right after I download them. Does anyone know a good API for this?
3) project them on the fly, perhaps with openlayers.im reading that can openlayers reproject,but can it be used over top of an osmdroid mapview?
Any ideas? Thanks for any help
Mike
GDAL is the way to go. There is no official Android build that I know of however some people have been successful in getting it running on Android. For example, Nutiteq has a build in the libs folder of their AdvancedMap3D sample project. Put the contents of both armeabi folders in your project's lib folder and you should be able to access the GDAL packages.
Then take a look at the GDAL in Java page. Look at the gdalinfo.java sample to get a feel for how to load and examine the parts of a GDAL dataset. To reproject your dataset, you will do something along the lines of:
SpatialReference sr = new SpatialReference();
sr.ImportFromProj4("+proj=merc +datum=WGS84");
String result[] = new String[1];
sr.ExportToPrettyWkt(result, 1);
String oldProjection = mDataset.getProjection();
String newProjection = result[0];
Dataset newDataset = gdal.AutoCreateWarpedVRT(mDataset, oldProjection, newProjection, gdalconst.GRA_NearestNeighbour, 0.0);
Dataset savedDataset = mDriver.CreateCopy(outpath, newDataset, 0, new String[] { "COMPRESS=LZW", "PREDICTOR=2" }, null, null);
newDataset.delete();
savedDataset.delete();
You may need to make a few adjustments, but that should get you most of the way there.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I am designing an android application where I want to plot real time data which I receive through bluetooth.
I receive a signal and process it to get some result and I want to display it in real time. I saw there are various android libraries for drawing charts. I am a bit confused as to go with one such library or to use Javascript. Can anyone suggest it which is a better option to go with? And also, which Android library to use?
There are many charting libraries for android but every time I had a requirement I used android native 2D graphics framework using Canvas. I never looked for other alternatives. It is simple and you have a lot of control. Well just to inform..
Its better to use flot-android-chart for different types of charts creation.
or you can simply use achartengine
if you want to try creating charts without any built in jars just look at this Bar Chart in Android With out any Built in jars(But it is only bar chart)
If you want a real-time chart for Android then the fastest Android Chart library is currently SciChart.
There is a performance comparison article which puts 5 open source and commercial charts head to head under real-time conditions and in all tests, SciChart comes out on top, sometimes by a considerable margin!
This makes SciChart suitable for real-time trading apps, medical apps, scientific apps and even embedded systems which run Android as an operating system.
Disclosure: I am the tech lead on the SciChart project, just so you know!
This repo look promising: Androidplot
It appears to support import from gradle rather than keeping a jar file locally. I also considered AnyChart, but it is a pay-to-use library, whereas Androidplot is offered under an Apache 2.0 license.
Screenshot from READme:
Just copying and pasting from their quickstart guide in case the link breaks:
Add the Dependency
To use the library in your gradle project add the following to your build.gradle:
dependencies {
compile "com.androidplot:androidplot-core:1.5.7"
}
If you’re using Proguard obfuscation (Projects created by Android Studio do by default) you’ll also
want add this to your proguard-rules.pro file:
-keep class com.androidplot.** { *; }
Create your Activity XML Layout
Once you’ve got an Android project skeleton created, create res/layout/simple_xy_plot_example.xml
and add an XYPlot view:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ap="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<com.androidplot.xy.XYPlot
style="#style/APDefacto.Dark"
android:id="#+id/plot"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ap:title="A Simple XY Plot"
ap:rangeTitle="range"
ap:domainTitle="domain"
ap:lineLabels="left|bottom"
ap:lineLabelRotationBottom="-45"/>
</LinearLayout>
This example uses a default style to decorate the plot. The full list of XML styleable attributes is
available here. While new attributes are added regularly,
not all configurable properties are yet available.
If something you need is missing, use Fig Syntax
directly within your Plot's XML, prefixing each property with "androidPlot". Example:
androidPlot.title="My Plot"
Create an Activity
Now let's create an Activity to display the XYPlot we just defined in simple_xy_plot_example.xml.
The basic steps are:
Create an instance of Series and populate it with data to be displayed.
Register one or more series with the plot instance along with a Formatter to describing how the series should look when drawn.
Draw the Plot
Since we're working with XY data, we’ll use XYPlot, SimpleXYSeries (which is an
implementation of the XYSeries interface) and LineAndPointFormatter:
import android.app.Activity;
import android.graphics.*;
import android.os.Bundle;
import com.androidplot.util.PixelUtils;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;
import java.util.*;
/**
* A simple XYPlot
*/
public class SimpleXYPlotActivity extends Activity {
private XYPlot plot;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_xy_plot_example);
// initialize our XYPlot reference:
plot = (XYPlot) findViewById(R.id.plot);
// create a couple arrays of y-values to plot:
final Number[] domainLabels = {1, 2, 3, 6, 7, 8, 9, 10, 13, 14};
Number[] series1Numbers = {1, 4, 2, 8, 4, 16, 8, 32, 16, 64};
Number[] series2Numbers = {5, 2, 10, 5, 20, 10, 40, 20, 80, 40};
// turn the above arrays into XYSeries':
// (Y_VALS_ONLY means use the element index as the x value)
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series1");
XYSeries series2 = new SimpleXYSeries(
Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");
// create formatters to use for drawing a series using LineAndPointRenderer
// and configure them from xml:
LineAndPointFormatter series1Format =
new LineAndPointFormatter(this, R.xml.line_point_formatter_with_labels);
LineAndPointFormatter series2Format =
new LineAndPointFormatter(this, R.xml.line_point_formatter_with_labels_2);
// add an "dash" effect to the series2 line:
series2Format.getLinePaint().setPathEffect(new DashPathEffect(new float[] {
// always use DP when specifying pixel sizes, to keep things consistent across devices:
PixelUtils.dpToPix(20),
PixelUtils.dpToPix(15)}, 0));
// just for fun, add some smoothing to the lines:
// see: http://androidplot.com/smooth-curves-and-androidplot/
series1Format.setInterpolationParams(
new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal));
series2Format.setInterpolationParams(
new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal));
// add a new series' to the xyplot:
plot.addSeries(series1, series1Format);
plot.addSeries(series2, series2Format);
plot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).setFormat(new Format() {
#Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
int i = Math.round(((Number) obj).floatValue());
return toAppendTo.append(domainLabels[i]);
}
#Override
public Object parseObject(String source, ParsePosition pos) {
return null;
}
});
}
}
One potentially confusing section of the code above are the initializations of LineAndPointFormatter
You probably noticed that they take a mysterious reference to an xml resource file. This is actually
using Fig to configure the instance properties from XML.
If you'd prefer to avoid the XML and keep everything in Java, just replace the code:
LineAndPointFormatter series1Format =
new LineAndPointFormatter(this, R.xml.line_point_formatter_with_labels);
with:
LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.RED, Color.GREEN, Color.BLUE, null);
In general XML configuration should be used over programmatic configuration when possible as it produces
more flexibility in terms of defining properties by screen density etc.. For more details on how to
programmatically configure Formatters etc. consult the latest Javadocs.
Continuing with the original example above, add these files to your /res/xml directory:
/res/xml/line_point_formatter_with_labels.xml
<?xml version="1.0" encoding="utf-8"?>
<config
linePaint.strokeWidth="5dp"
linePaint.color="#00AA00"
vertexPaint.color="#007700"
vertexPaint.strokeWidth="20dp"
fillPaint.color="#00000000"
pointLabelFormatter.textPaint.color="#CCCCCC"/>
/res/xml/line_point_formatter_with_labels_2.xml
<?xml version="1.0" encoding="utf-8"?>
<config
linePaint.strokeWidth="5dp"
linePaint.color="#0000AA"
vertexPaint.strokeWidth="20dp"
vertexPaint.color="#000099"
fillPaint.color="#00000000"
pointLabelFormatter.textPaint.color="#CCCCCC"/>