10. Media
ARGear provides image or video capture through ARGMedia. Users can take a photo or shoot a video in the available ratios, 16:9, 4:3, 1:1.
10.1 Take a Photo
Using the takePicture function in ARGMedia, users can take a photo.
The function must be called in gl thread environment.
Sample code is written below.
ARGMedia argmedia = new ARGMedia(argsession);
GLView.GLViewListener glViewListener = new GLView.GLViewListener() {
@Override
public void onDrawFrame(GL10 gl, int width, int height) {
ARGFrame frame = mARGSession.drawFrame(gl, width, height);
if (argmedia != null) {
if (mIsShooting) {
String path = Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".jpg";
argmedia.takePicture(frame.getTextureId(), path, ARGMedia.Ratio.RATIO_4_3);
}
}
}
};var argmedia = ARGMedia(argsession)
override fun onDrawFrame(gl: GL10?, width: Int?, height: Int?) {
val localWidth = width ?: 0
val localHeight = height ?: 0
val frame = argsession.drawFrame(gl, localWidth, localHeight)
frame?.let {
if (isShooting) {
val path = mediaPath + "/" + System.currentTimeMillis() + ".jpg"
argmedia.takePicture(textureId, path, ARGMedia.Ratio.RATIO_4_3)
}
}
}10.2 Record a Video
ARGMedia provides several functions to record a video. Through the functions you can control bitrate, silent mode, and video frame size ratio.
Sample code to record a video is written below.
Last updated
Was this helpful?