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”. mview is consistently used without declaration throughout the code — is it from another file I’m supposed to be importing? Any ideas? Thanks
B
The “m” in
mViewindicates that it is a member variable. It’s a language naming convention used in most Android apps (you can read more about it here if you feel so inclined). So just add the following inside MyActivity:That should resolve your
mView cannot be resolved to a variableerror, which is just a scoping issue.On that page it says to refer to the
15-puzzlesample for more details. I suggest taking a look at it here.I agree it is a little confusing. Since OpenCV is open source, feel free to send them a GitHub pull request with an amendment to this part of the documentation.