Real time camera effect

  • Replies:5
Rimpy
  • Forum posts: 17

May 8, 2012, 8:18:25 AM via Website

Hi,

I have stuck in issue of how to set real time camera effects like sepia, negative,aqua and so on.
But its nothing seems to work.So please suggest your positive ideas.

Thanks,

Reply
Eric McBride
  • Forum posts: 1,790

May 9, 2012, 5:58:44 PM via Website

Would you mind stating which device you have?

Reply
Rimpy
  • Forum posts: 17

May 9, 2012, 7:25:49 PM via Website

Hi,

I have LG Optimus device.

Thanks,

Reply
Jeremiah
  • Forum posts: 775

May 10, 2012, 4:04:49 AM via Website

Rimpy
Hi,

I have stuck in issue of how to set real time camera effects like sepia, negative,aqua and so on.
But its nothing seems to work.So please suggest your positive ideas.

Thanks,

I assume this is a development question, being the developers forum. What you need to do is set the camera parameters: http://developer.android.com/reference/android/hardware/Camera.Parameters.html There are built in camera parameters such as sephia, negative and so on.

First get a parameter object for the camera:
Camera.Parameters p = mCamera.getParameters();

Set the effect you want in the parameter:
p.setColorEffect (Camera.Parameters.EFFECT_SEPIA);

Apply the parameter to your camera object:
mCamera.setParameters(p);

Reply
Rimpy
  • Forum posts: 17

May 10, 2012, 7:44:22 AM via Website

Hi,

I had implemented these three line of code in my project.
All these effects we can saw on sd card not in real time.
I want all these effects during video recording.Having code for easily uderstable for you.
So please again give me your help.
1//
2VideoTestActivity.java
3
4package com.videoTest;
5
6import java.io.File;
7
8import android.app.Activity;
9import android.content.Intent;
10import android.hardware.Camera;
11import android.net.Uri;
12import android.os.Bundle;
13import android.os.Environment;
14import android.provider.MediaStore;
15import android.view.View;
16import android.widget.Button;
17import android.widget.TextView;
18
19public class VideoTestActivity extends Activity {
20
21 private static final int REQUEST_VIDEO = 100;
22
23 Button captureButton;
24
25 TextView text;
26 File destination;
27 Camera camera;
28
29 @Override
30 public void onCreate(Bundle savedInstanceState) {
31 super.onCreate(savedInstanceState);
32 setContentView(R.layout.main);
33
34 captureButton = (Button)findViewById(R.id.capture);
35 captureButton.setOnClickListener(listener);
36
37 captureButton = (Button)findViewById(R.id.capture);
38 captureButton.setOnClickListener(listener);
39 text = (TextView)findViewById(R.id.file);
40
41
42
43 destination = new File(Environment.getExternalStorageDirectory(),"myVideo");
44 }
45
46 @Override
47 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
48 if(requestCode == REQUEST_VIDEO && resultCode == Activity.RESULT_OK) {
49 String location = data.getData().toString();
50 text.setText(location);
51 }
52 }
53
54 private View.OnClickListener listener = new View.OnClickListener() {
55 @Override
56 public void onClick(View v) {
57 /*Camera.Parameters parameters = camera.getParameters();
58 parameters.setColorEffect(Camera.Parameters.EFFECT_NEGATIVE);
59 camera.setParameters(parameters);*/
60 Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
61
62 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(destination));
63 intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
64
65 // intent.filterHashCode();
66 startActivityForResult(intent, REQUEST_VIDEO);
67 intent.setType("*/*");
68 intent.setType("image/*");
69 intent.setType("video/*");
70 }
71 };
72}
73///
74main.xml
75<?xml version="1.0" encoding="utf-8"?>
76<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
77 android:orientation="vertical"
78 android:layout_width="fill_parent"
79 android:layout_height="fill_parent">
80 <Button
81 android:id="@+id/capture"
82 android:layout_width="fill_parent"
83 android:layout_height="wrap_content"
84 android:text="Take a Video"
85 />
86 <Button
87 android:id="@+id/Effects"
88 android:layout_width="fill_parent"
89 android:layout_height="wrap_content"
90 android:text="Effects"
91 android:visibility="gone"
92 />
93 <TextView
94 android:id="@+id/file"
95 android:layout_width="fill_parent"
96 android:layout_height="fill_parent"
97 />
98</LinearLayout>
Thanks,

— modified on May 10, 2012, 7:52:58 AM

Reply
Jeremiah
  • Forum posts: 775

May 15, 2012, 5:36:44 AM via Website

I'm not sure if the camera api will display the effects in the preview. Most likely you will have to create the effect yourself from the pixel data grabbed from the camera preview. This is a lot harder and takes some understanding of how to program the image effects. Here is a page I found that might get you started: http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array

Reply