samsung galaxy s 4g front cam app help - Android Software Development

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!

Related

Drawing on top of a camera view

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

Image Low Quality

Hey,
So I'm making an app that needs to display a bitmap or raw (something where X/Y pixels can be modified, so no compression like a jpg).
There's an Activity which contains only an ImageView, I get the Bitmap from the bundle given in the callback from the camera (it's put into the intent before the Activity starts), then I set it to the ImageView in onCreate of this new Activity (which is basically only an ImageView).
For some reason, when viewing this Activity, the picture is of EXTREMELY low quality. Like, tons of jaggies, like it's a thumbnail or something and is force-scaled up to the screen size. The image isn't really like this, though, when I view it in my gallery it's crystal clear. So why is the quality being dragged down to all hell when I set it in the ImageView? I don't care about the performance constraints, this isn't a production app.
I feel there's some quality control function in the ImageView or something, but I have no idea what. Can somebody tell me the "why" or the "fix" - plzzzz - I'm on a really truncated time schedule and haven't had much luck with this camera for too long .
TIA
Syndacate said:
Hey,
So I'm making an app that needs to display a bitmap or raw (something where X/Y pixels can be modified, so no compression like a jpg).
There's an Activity which contains only an ImageView, I get the Bitmap from the bundle given in the callback from the camera (it's put into the intent before the Activity starts), then I set it to the ImageView in onCreate of this new Activity (which is basically only an ImageView).
For some reason, when viewing this Activity, the picture is of EXTREMELY low quality. Like, tons of jaggies, like it's a thumbnail or something and is force-scaled up to the screen size. The image isn't really like this, though, when I view it in my gallery it's crystal clear. So why is the quality being dragged down to all hell when I set it in the ImageView? I don't care about the performance constraints, this isn't a production app.
I feel there's some quality control function in the ImageView or something, but I have no idea what. Can somebody tell me the "why" or the "fix" - plzzzz - I'm on a really truncated time schedule and haven't had much luck with this camera for too long .
TIA
Click to expand...
Click to collapse
what other info does the camera intent return, what extras?
alostpacket said:
what other info does the camera intent return, what extras?
Click to expand...
Click to collapse
How do I check?
I used somebody else's tutorial to learn that the URI is in the 'data' of the bundle.
I tried checking earlier by using its to-string, but that just gave me the container size.
Syndacate said:
How do I check?
I used somebody else's tutorial to learn that the URI is in the 'data' of the bundle.
I tried checking earlier by using its to-string, but that just gave me the container size.
Click to expand...
Click to collapse
you probably have the URI to the thumbnail
Post the tutorial you used and some code, shouldn't be too hard to figure out.
alostpacket said:
you probably have the URI to the thumbnail
Post the tutorial you used and some code, shouldn't be too hard to figure out.
Click to expand...
Click to collapse
There's like upteen thousand tutorials that I compiled to make what I have.
I have no "links" anymore.
I got the Intent from the camera in the onActivityResult function after calling the camera. I pulled the bundle from it using the getExtras() function on the intent.
I then passed that intent to the new Intent I made to create my second Activity. I passed it via the putExtras function on the new intent.
In essence, I did;
Code:
Intent in = new Intent();
in.putExtras(incoming_intent_from_camera.getExtras());
And then called my second Activity.
In the onCreate() function of my second Activity, I pull the bitmap data using:
Code:
Bitmap bmp = (Bitmap)getIntent().getExtras().get("data");
There are two things in this Bundle, data (a Bitmap (android.graphics.Bitmap)) and a bitmap-data, which is a boolean.
EDIT:
Yes, it is definitely the URI to the thumbnail, I need the large image URI.
I have a feeling the problem is that it needs the EXTRA_OPTION string, the only issue is, I don't want to save this any place in particular. I'll let the camera save it to the default location on my SDCard. I just want the URI to that full size or something usable.
I can't do:
Code:
intent.putExtra(MediaStore.EXTRA_OPTION, <URI>);
Because I don't have nor want an additional URI to store it... I got to get EXTRA_OPTION to the camera somehow..
Okay, so here's the deal, that apparently nobody was able to help me with ():
- Like alostpacket said, the "data" key in the bundle returned from the camera activity (in the callback) contains the URI to the thumbnail - that's useless unless I'm making an icon or some other small/tiny/low res picture.
I was correct in the fact that it had something to do with putting the EXTRA_OPTION into the extras that I passed off to the camera intent.
This DID come at a price, though. You have to make a temporary place to store the image (you know, because the regular one in the gallery just isn't good enough of or something). And by temporary I kind of mean permanent, it gets overwritten every time (assuming you use the same path), but won't get removed. I am unable to understand this functionality. If somebody could explain it that would be great.
So all in all my intent to the camera looks like this:
Code:
image_path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp_image.jpg";
File img = new File (image_path);
Uri uri = Uri.fromFile(img);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, PICTURE_REQUEST);
Where image_path is a private class String and PICTURE_REQUEST is a final String (also class level scope) - which can represent any non-0 number, but is unique to the request (think of it as a request ID).
Then, in the callback function, after checking to make sure the request code is PICTURE_REQUEST, and the resultCode was OK:
Code:
Bitmap bmp = BitmapFactory.decodeFile(image_path);
img_view.setImageBitmap(bmp);
img_view.invalidate();
Where image_path is (a String) wherever the image specified as an extra to the camera activity, img_view is an ImageView display element. The invalidate method will redraw the ImageView.
I hope that helps somebody else stuck in the same position I am.
I'm going to leave this question as "unresolved" because there's one thing I still can't figure out. The "EXTRA_OUTPUT" extra passed to the intent seems like a work-around. All that does is define an alternate path to write the file to, then the callback (or whatever) grabs it from there. It's a hack and a half. There has to be a legit way to grab the full quality image taken with the camera. Whether that's accessing the gallery intent or not I'm not sure, but this is definitely a work around. I hope somebody can provide the answer to that, because a lot of tutorials mention the EXTRA_OUTPUT method, and given what it does, I don't believe that is correct.

open front camera using camera API

how to open front, camera using camera API in android.
Code:
private Camera trythis ;
trythis = Camera.open (CameraInfo.CAMERA_FACING_FRONT);

[Q] In-App Video Recording

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.

[Q] Activate continuous auto-focus on Samsung sm-c105

Hi everyone,
I am currently developing a camera application for the Samsung galaxy s4 zoom (sm-c105). I would like to activate the continuous auto-focus.
Here is what I do. It's working on my galaxy s5:
Code:
mCamera = Camera.open(defaultCameraId);
Camera.Parameters params = mCamera.getParameters();
if (params.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE )) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
I have tried all the other focus mode, but nothing is working. Even when i request focus with a callback, nothing is happening.
The galaxy s4 zoom use a special camera lens. I think this the source of my issue. I searched for a special camera api from Samsung but I didn't found nothing.
Would you have any leads?
Thanks.

Categories

Resources