Ask Your Question
0

Hello OpenCV Android Sample Code - mview confusion

asked 2013-01-29 18:51:58 -0600

bdg26 gravatar image

Hi All, I'm trying the tutorial located here

I have compiled sample code for openCV without issues - so I'm sure I have all the necessary things installed for opencv. I've added the opencv library to my project and I'm compiling with java 1.6 (java 7 doesn't work with opencv4android right now AFAIK). I added the opencv library as a resource as well.

However, the sample code doesn't make sense to me once it gets to step 5 under Hello OpenCV example.

   public void onCreate (Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     mView = new HelloOpenCVView(this);
     setContentView (mView);
}

Is the code I'm talking about, I immediately get the error "mView cannot be resolved to a variable". I can resolve it by putting HelloOpenCVView mView = new HelloOpenCVView(this) but that just causes a bunch of other problems later on. Can someone tell me what I'm doing wrong? thanks

B

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-01-29 20:11:18 -0600

matt.hammer gravatar image

mView is probably supposed to be a data member of the HelloOpenCVActivity class. (mXXXXX being an old convention for naming member variables).

So you would probably see something like this:

HelloOpenCVView mView;

some where close to the top of the HelloOpenCVActivity class. The "bunch of problems later on" you get when you try

HelloOpenCVView mView = new HelloOpenCVView(this);

inside onCreate() are probably scope-related, as other functions in the HelloOpenCVActivity class didn't have access to mView when you tried this. (looking at the example code, onPause() and onResume also refer to mView).

If this doesn't solve your problem, posting more error information/output would be helpful.

edit flag offensive delete link more

Comments

Thanks for your help, you were right I needed to just define mview towards the top of the HelloOpenCVActivity class, most of the other errors I got were solved by importing the correct libraries. I'm now able to compile the code completely, but it crashes when I move it to my device. I need to look into the errors, but I have a feeling I'm going to be back asking questions pretty shortly. Thanks for the quick helpful response

bdg26 gravatar imagebdg26 ( 2013-01-29 21:15:23 -0600 )edit

Question Tools

Stats

Asked: 2013-01-29 18:51:58 -0600

Seen: 342 times

Last updated: Jan 29 '13