Hi there. I'm making an AR app and I couldn't figure out a way to draw on top of a camera view. I've created a custom SurfaceView class which uses Camera.startPreview and Camera.setPreviewDisplay to draw the real time feed from the camera upon it. Now I'm trying to render something on it. I have another SurfaceView which has a painter thread which is running with 30 fps and is drawing every frame on a Canvas obtained by SurfaceHolder.lockCanvas(). I put the two views in a FrameLayout like this
Code:
Preview cv = new Preview(
this.getApplicationContext());
Pano mGameView = new Pano(this.getApplicationContext());
FrameLayout rl = new FrameLayout(
this.getApplicationContext());
setContentView(rl);
rl.addView(cv);
rl.addView(mGameView);
And sadly it doesn't work. It shows only the camera feed. If I switch the order like this
Code:
rl.addView(mGameView);
rl.addView(cv);
The camera feed dissipates and only the painter is visible...
How should I make it work
Phew. Just to tell you I found a solution. You add this line
Code:
getHolder().setFormat(PixelFormat.TRANSLUCENT);
in the initialization of your overlay view
Hello,
I'm trying to make a simple app where it uses the front cam to take a pic. The problem is that I just want see the preview or view finder (what ever you call it), also to make it smaller.
can any one help?
here what i got so far
Code:
Camera camera = Camera.open();
Camera.Parameters parameters = camera.getParameters();
parameters.set("camera-id", 2);
camera.setParameters(parameters);
any help? it do not have to be with SGS4G it can be for any phone!
how to open front, camera using camera API in android.
Code:
private Camera trythis ;
trythis = Camera.open (CameraInfo.CAMERA_FACING_FRONT);
I came across a service named "TestFairy", and I am interested in some of it's features, but it's TOS does not agree with my application. So, I wanted to ask if anyone knows how one could implement the In-App recording feature used in TestFairy in an Android application without root. I have already done some Googling to no avail, and I am just starting to make Android apps, so I don't know how this can be done.
You can see what feature I am talking about at testfairy.com by clicking "Demo" at the top or watching their intro video.
Edit: It would appear that it is implemented by screenshots in rapid succession. How could I do this or (better yet) just record a video of just my application without root?
If you only want to record the video on your device, you could use the new screenrecord shell command in KitKat
https://developer.android.com/about/versions/kitkat.html#44-screen-recording
painlessDeath said:
If you only want to record the video on your device, you could use the new screenrecord shell command in KitKat
https://developer.android.com/about/versions/kitkat.html#44-screen-recording
Click to expand...
Click to collapse
Thank you for mentioning it, but this doesn't work without root or without a computer, and I am trying to support devices down to Gingerbread, not just KitKat.
Ohh, I thought you just wanted to create a video demo of your app.
To add support for recording video for your own app, you would take the root view of your app, and add the screenshots of the view periodically to a video.
Example code
Code:
// The root view you want to record.
View rootView = getWindow().getDecorView();
rootView.setDrawingCacheEnabled(true);
// Record the view in a separate thread.
new AsyncTask<View, Void, Void>() {
@Override
protected Void doInBackground(View... params) {
View source = params[0];
long time;
int fps = 30;
long frameDuration = 1000 / fps;
while (!isCancelled()) {
time = System.currentTimeMillis();
addBitmpToVideo(source.getDrawingCache(), frameDuration);
Thread.sleep(frameDuration);
}
return null;
}
}.execute(rootView);
You would have to implement addBitmpToVideo.
You could either user ffmpeg for this or if you only want ICS+ support, you could try using the hidden videoeditor API
http://stackoverflow.com/questions/14197757/android-video-editor-classes
painlessDeath said:
Ohh, I thought you just wanted to create a video demo of your app.
To add support for recording video for your own app, you would take the root view of your app, and add the screenshots of the view periodically to a video.
Example code
Code:
// The root view you want to record.
View rootView = getWindow().getDecorView();
rootView.setDrawingCacheEnabled(true);
// Record the view in a separate thread.
new AsyncTask<View, Void, Void>() {
@Override
protected Void doInBackground(View... params) {
View source = params[0];
long time;
int fps = 30;
long frameDuration = 1000 / fps;
while (!isCancelled()) {
time = System.currentTimeMillis();
addBitmpToVideo(source.getDrawingCache(), frameDuration);
Thread.sleep(frameDuration);
}
return null;
}
}.execute(rootView);
You would have to implement addBitmpToVideo.
You could either user ffmpeg for this or if you only want ICS+ support, you could try using the hidden videoeditor API
http://stackoverflow.com/questions/14197757/android-video-editor-classes
Click to expand...
Click to collapse
Thanks! I will try this out when I get the chance.
Hi, we know the camera app won't use the 4x tele zoom until we zoom at 10x, even when lighting conditions are good enough and the zoom camera would give much better results (we know that from comparison with GCam).
While looking at the output of adb shell dumpsys media.camera, I noticed a suspicious samsung.android.scaler.zoomMapRatio variable with a value of 10.
With the command adb shell am start -a android.media.action.IMAGE_CAPTURE --ei samsung.android.scaler.zoomMapRatio 0 I can start the camera app and force this variable to zero... And suddenly the app switches between the main and the zoom cameras between 4x and 5x (depending on your lighting conditions) !
Now I need to find a way to start the camera on the phone with this command line - the setting is lost when closing the app.
Video demonstation - I run the adb command at 5s:
Please be aware that the Themes/Apps section is ONLY for releasing themes and apps.
Discussions like this go in the General section.
Thread moved.
V0latyle said:
Please be aware that the Themes/Apps section is ONLY for releasing themes and apps.
Discussions like this go in the General section.
Thread moved.
Click to expand...
Click to collapse
My bad, thx for the cleanup
I'm not sure what's the best way to launch the camera while forcing this setting...
I can write a launcher app, but the following code does work except we only get to take a photo - we cannot change mode (photo/video/portrait/etc.)
Code:
val takePictureIntent = Intent1(MediaStore.ACTION_IMAGE_CAPTURE)
takePictureIntent.putExtra("samsung.android.scaler.zoomMapRatio", 0) // <== Magic !
try {
startActivityForResult(takePictureIntent, pic_id);
} catch (e: Exception) {
// display error state to the user
}
The result in video: