Create an EGLContext in C++ and bind it to a Java GLSurfaceView - java

i try to create an EGLContext in C++ and bint it to a GLSurfaceView.
After some research on google and even here, i don't see something close to my problem.
It is possible to do this ?
I already know that i can do a NativeActivity, but i also need to use Java library for Loading Image, Audio, make HttpRequest, get Device information, etc.
Any help is welcome.

Related

How can I read and show an .obj in Wikitude Native API?

I am trying to use Wikitude Native API to write an Android App. I see the Sample code and build imageTracker. I want to make a customView with other .obj from internet on the recognized image. Can any one give some idea or sample code to me please.
What I understand now is that, I should change the strokedRectangle to my objectLoader, and put it into glRenderer.setRenderablesForKey. The objectLoader should extends Renderable. However, what should I do next?
public void onImageRecognized(ImageTracker tracker, final ImageTarget target) {
Log.v(TAG, "Recognized target " + target.getName());
StrokedRectangle strokedRectangle = new StrokedRectangle(StrokedRectangle.Type.STANDARD);
glRenderer.setRenderablesForKey(target.getName() + target.getUniqueId(), strokedRectangle, null);
}
The Wikitude Native SDK itself is oblivious to the concept of augmentation rendering. All the related code (StrokedRectangle, Renderable, Renderer, etc.) is part of the example application layer only, meaning you can get rid of all of it and implement the rendering as you see fit. These classes merely serve as a demonstration of how one could implement the rendering.
Ultimately, all you need to do is receive a view matrix and the field of view from the Wikitude SDK and use them as your rendering input. You will need to create a projection matrix from the latter, which the sample code demonstrates as well.
If you should require additional assistance with the implementation, I'd be happy to have an extended discussion in the Wikitude forums. Stackoverflow does not seem to me to be the appropriate place for such support matters.

VLCj: How to set motion blur?

I am developing an interactive video player and would like to dynamically set motion blur using VLCj 3.0.1. Since EmbeddedMediaPlayer doesn't provide some kind of setBlur method, I guess I am supposed to use addMediaOptions(String... options).
However, I haven't been able to figure out how to use it. Starting VLC from the command line I would have to add the following parameters --video-filter=motionblur blur-factor=44. Providing the same parameter in an array, doesn't show any effect though. I would be glad, if someone could show me the correct syntax. This is essentially my code:
EmbeddedMediaPlayerComponent vlc = new EmbeddedMediaPlayerComponent();
EmbeddedMediaPlayer player = vlc.getMediaPlayer();
player.playMedia(path);
String[] options = { "video-filter=motionblur", "blur-factor=" + blur };
player.addMediaOptions(options);
In your example code you are adding options after you play the media, that might work in some instances but you should really (generally) just pass them in as additional parameters on your playMedia call.
However...
Some of those options that are not directly supported by a LibVLC API function must be passed when you create the LibVLC instance (i.e. the vlcj MediaPlayerFactory) rather than when you play media.
Since you are using EmeddedMediaPlayerComponent then you should subclass your EmbeddedMediaPlayerComponent and override onGetMediaPlayerFactoryArgs() and pass your motion blur options, along with whatever else you need, there.
Note that you need to send the exact command-line switches, so you must prefix your options with "--".
There is an example of doing precisely that in the vlcj Javadoc for EmbeddedMediaPlayerComponent.
People often ask is there any documentation describing how each of the available VLC options can be set - the short answer is no there is not, and that any use of options like this is totally unsupported and may not work with a future version of VLC/LibVLC.
Ideally, enabling motion blur would be achievable by a new LibVLC API function, but someone would have to write a patch for VLC to make that happen.

UIImage, imageWithData in Android?

I'm fairly new in Android development so please forgive me if it's a stupid question.
Basically I have an iPhone app,which will compress UIImage into NSData, using UIImageJPEGRepresentation method, this is not a problem.
The question begins when I am trying to read this data on an Android device. I'm transferring the image data (NSData)from iPhone to Android, and I want to display the image on Android. How should I do so?
Is there any customised class that can do function similar to UIImage imageWithData in Java, that can decode the data and turn it into Bitmap?
Or should I try to encode and decode using a different but stand method? If so, what are the options?
Thank you so much for your help!
After further digging and researching, I found some interesting and useful classes if anyone is interested.
https://code.google.com/p/crossmobile/source/browse/src/xmioslayer/src/org/xmlvm/iphone/?r=68eaa3b2fa6ee05e8034bd517b45b490c50c7bb7
This is google cross mobile code, with them, you can use NSData and other class method that was originally meant for iOS developing.
However that's not how I solve the problem above.
There're two ways to pass an image from iPhone(UIImage) to Android(Bitmap), or the other way around.
First, upload the image into your own server, (by using AFNetwork in iOS, not sure about android), then get the url of the image, then pass this url to the other device as a string.
Or, convert UIImage to NSData, then from NSData to NSString (using Base64Encoding), then use NSJsonSerializatioin to parse whatever NSString, NSArray or NSDictionary to Json Object. Send the Json object, and try to decode it on the other device.
Although the first method is recommended, I actually went with the second one since I wish to deal the data locally with or without internet.
If anyone needs sample code, just ask, I'll post.
And that's pretty much it! Happy coding!

Use android.graphics.Bitmap from Java without Android

I need to use android.graphics.Bitmap in my Java project without Android platform. The problem is that I want to process the picture which comes to the server from Android device as a Bitmap.
So, I need some methods that use native code. How can I get these native methods? I tried to find them at http://androidxref.com but if I have, for example,
static int Bitmap_width(JNIEnv* env, jobject, SkBitmap* bitmap) {return bitmap->width();}
clicking width() refers to the new search where there are lots of classes contating different width().
You shouldn't do that. The android libraries are not meant to be used for non android applications. Especially the native code.
As long as you send a bitmap image, any non-android library will be able to read it.
You can event send the image raw pixels. It's like sending a list of bytes. Any language will be able to read incomming bytes.
I managed to do this. Now the server gets only width, height of the image and array of pixels derived by bitmap.getPixels(...) on the device and builds the picture as described here

Java library for creating 3d-objects for 3d printing

I am looking for a java library to create 3d-geometries and then convert that to .stl files so I can 3d print my object using a 3d printer.
I can imagine using a 3d-graphics object where one can draw the same like on a graphics2d object:
Buffered3DObject obj = new Buffered3DObject(200,200,200, Unit.MM);
Graphics3D g3 = obj.getGraphics();
Stroke3d stroke = new Stroke(3);
g3.setStroke(stroke);
g3.drawpipe(x1,y1,z1,x2,y2,z2);
obj.exportToSTL("filename.stl");
Ok, I am just making up code :). But something like this.
Anybody know how I could pull something like this off? Any opensource libs that does stuff like this?
Would be nice to be able to generate a customized object through user input from a website.
Rob.
Edit:
Even though the question is closed (and nobody cared to answer my question on why) I found my answer (I post it so others with the same question can find it):
There is a java library on its way as a wrapper around OpenScad. The java wrapper is called JavaScad. Can be found here JavaScad
There is a java library which works as a wrapper around OpenScad. The java wrapper is called JavaScad. Can be found here JavaScad. It works fine and I actually contributed to the library already.
JCSG - Java implementation of BSP based CSG (Constructive Solid Geometry)
jsolid - wrapper around JCSG providing fluent API
Another option is: abfab3d.com This is opensourced code from Shapeways. Its is more complex and uses voxels as a base, but can convert to mesh aswell.
The code is at github: abfab3d # github
I have not tried it, but will as the openscad route is slow and difficult to integrate in a webserver, so I will try it once I have time.

Categories

Resources