开发者

Calling an integer to a method cast in a private void

开发者 https://www.devze.com 2023-01-26 04:56 出处:网络
I am in a single class, using 2 different methods. In one method I have: private void detect(); int facesFound = detector.findFaces(bitmap565, faces);

I am in a single class, using 2 different methods.

In one method I have:

private void detect();
    int facesFound = detector.findFaces(bitmap565, faces);

detector, bitmap565 and faces are all defined in the same method.

In another method, I would like to call the value of facesFound.

So:

开发者_如何学Pythonprivate void crop(){
if (facesFound > 1){

}

My issue is, I cannot access that integer from the method because it is cast locally. What is my best way to alter my code to call it?

Edit: to add method:

private final View.OnClickListener btnClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
   case R.id.action_button:
        crop();

So are you saying declare an integer at the top of my class that is defined as getting the integer passed back through my new private int detect() method?


Change detect() and crop() to:

private int detect()
{
    return detector.findFaces(bitmap565, faces);
}

private void crop(int numberOfFacesFound)
{
    if(numberOfFacesFound > 1)
    {

    }
}

Then, wherever you are calling crop() from:

int numberOfFacesFound = detect();
crop(numberOfFacesFound);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号