Draw on Camera Preview?

All your problems with Audio, Video and Images.

Draw on Camera Preview?

Postby jerrygarciame » Wed Mar 31, 2010 5:01 am

Any good articles, suggestions, etc. for drawing graphics on the camera preview? i.e. for augmented reality apps.

Thanks!
jerrygarciame
Freshman
Freshman
 
Posts: 9
Joined: Tue Mar 30, 2010 4:25 am

Top

drawing graphics on the camera preview

Postby szakal » Thu Apr 15, 2010 8:43 am

have a look at ZXING project, there is a ViewFinderView class which provide drawing graphics on the camera preview.

http://code.google.com/p/zxing/source/b ... rView.java

This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
transparency outside it, as well as the laser scanner animation and result points.


regards David
szakal
Freshman
Freshman
 
Posts: 3
Joined: Thu Apr 15, 2010 8:14 am
Location: 52.4164, 16.9243

Re: drawing graphics on the camera preview

Postby m.francia » Tue Apr 20, 2010 8:35 am

szakal wrote:have a look at ZXING project, there is a ViewFinderView class which provide drawing graphics on the camera preview.

http://code.google.com/p/zxing/source/b ... rView.java

This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
transparency outside it, as well as the laser scanner animation and result points.


regards David
useful!!!
thanks
Image
User avatar
m.francia
Freshman
Freshman
 
Posts: 5
Joined: Wed Mar 24, 2010 2:11 pm

Postby beewest » Fri Apr 23, 2010 5:01 am

I found this simple code from the Internet. Work well.

public class MMCC extends Activity {
Preview mPreview;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Hide the window title.
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

// Create our Preview view and set it as the content of our activity.
mPreview = new Preview(this);
GuideBox guideBox = new GuideBox(this);

//camera preview
setContentView(mPreview);
//overlay guide box
addContentView(guideBox, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

}
...
}

public class GuideBox extends View {
public GuideBox(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub

Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.GREEN);

//center
int x0=canvas.getWidth()/2;
int y0=canvas.getHeight()/2;
int dx=canvas.getHeight()/3;
int dy=canvas.getHeight()/3;

//draw guide box
canvas.drawRect(x0-dx, y0-dy, x0+dx, y0+dy, paint);

super.onDraw(canvas);
}
}
beewest
Freshman
Freshman
 
Posts: 2
Joined: Tue Apr 20, 2010 7:21 am

Postby m.francia » Tue Apr 27, 2010 2:01 pm

I've tried the code posted by beewest and it works pretty good, I've only a question:
I'm gonna use that approach to implement an AR application, so I'll create several views (GuideBox in the above example) and draw different objects on every View e.i. a view containing the Buttons, a View containing the labels with the street name and so on....

is that a good way to implement an AR application or it will bring me to overactive cpu, memory expansive application and stuff like that?

so how should I implement my "overlapped layers"?

Thanks for the help and sorry for my English.
Image
User avatar
m.francia
Freshman
Freshman
 
Posts: 5
Joined: Wed Mar 24, 2010 2:11 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 11 guests