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() {@Overridepublic 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 ?: 0val localHeight = height ?: 0val 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)}}}
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.
ARGMedia argmedia = new ARGMedia(argsession);private void startRecording() {int bitrate = 10 * 1000 * 1000; // 10Mint [] previewSize = mCamera.getPreviewSize();mVideoFilePath = Environment.getExternalStorageDirectory() + "/" + System.currentTimeMillis() + ".mp4";// Initiate Recorderargmedia.initRecorder(mVideoFilePath,previewSize[0], previewSize[1], bitrate,false, false, false, ARGMedia.Ratio.RATIO_4_3);// Start Recordingargmedia.startRecording();}private void stopRecording() {// Stop Recordingargmedia.stopRecording();}GLView.GLViewListener glViewListener = new GLView.GLViewListener() {@Overridepublic void onDrawFrame(GL10 gl, int width, int height) {ARGFrame frame = mARGSession.drawFrame(gl, width, height);if (argmedia != null && argmedia.isRecording()) {// Update Recording Frameargmedia.updateFrame(frame.getTextureId());}}};
var argmedia = new ARGMedia(argsession);private fun startRecording() {val bitrate = 10 * 1000 * 1000 // 10Mval previewSize: IntArray? = camera.previewSizeval videoFilePath = mediaPath + "/" + System.currentTimeMillis() + ".mp4"argMedia.initRecorder(videoFilePath, previewSize[0], previewSize[1], bitrate,false, false, false, ARGMedia.Ratio.RATIO_4_3)argMedia.startRecording()}private fun stopRecording() {argmedia.stopRecording()}override fun onDrawFrame(gl: GL10?, width: Int?, height: Int?) {val localWidth = width ?: 0val localHeight = height ?: 0val frame = argsession.drawFrame(gl, localWidth, localHeight)frame?.let {if (argmedia.isRecording) argmedia.updateFrame(it.textureId)}}