我得到了这种奇怪的行为,即在进行git克隆并在另一台机器上构建之后,我无法将package com.hehe.trumpcard;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.util.Log;
import android.view.WindowManager;
import org.opencv.android.*;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
import org.opencv.core.*;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
public class Main3Activity extends AppCompatActivity implements CvCameraViewListener {
private CameraBridgeViewBase openCvCameraView;
private CascadeClassifier cascadeClassifier;
private Mat grayscaleImage;
private int absoluteFaceSize;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status){
case LoaderCallbackInterface.SUCCESS:
initializeOpenCVDependencies();
break;
default:
super.onManagerConnected(status);
break;
}
}
};
private void initializeOpenCVDependencies(){
try{
// Copy the resource into a temp file so OpenCV can load it
InputStream is = getResources().openRawResource(R.raw.haarcascade_fullbody);
File cascadeDir = getDir("cascade", Context.MODE_APPEND);
File mCascadeFile = new File(cascadeDir, "haarcascade_fullbody.xml");
FileOutputStream os = new FileOutputStream(mCascadeFile);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = is.read(buffer)) != -1) {
os.write(buffer, 0, bytesRead);
}
is.close();
os.close();
// Load the cascade classifier
cascadeClassifier = new CascadeClassifier(mCascadeFile.getAbsolutePath());
} catch (Exception e) {
Log.e("OpenCVActivity", "Error loading cascade", e);
}
// And we are ready to go
openCvCameraView.enableView();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
openCvCameraView = new JavaCameraView(this, -1);
setContentView(openCvCameraView);
openCvCameraView.setCvCameraViewListener(this);
//setContentView(R.layout.activity_main);
}
@Override
public void onCameraViewStarted(int width, int height) {
grayscaleImage = new Mat(height, width, CvType.CV_8UC4);
// The faces will be a 20% of the height of the screen
absoluteFaceSize = (int) (height * 0.2);
}
@Override
public void onCameraViewStopped() {
}
@Override
public Mat onCameraFrame(Mat aInputFrame) {
// Create a grayscale image
Imgproc.cvtColor(aInputFrame, grayscaleImage, Imgproc.COLOR_RGBA2RGB);
MatOfRect faces = new MatOfRect();
// Use the classifier to detect faces
if (cascadeClassifier != null) {
cascadeClassifier.detectMultiScale(grayscaleImage, faces, 1.1, 2, 2,
new Size(absoluteFaceSize, absoluteFaceSize), new Size());
}
// If there are any faces found, draw a rectangle around it
Rect[] facesArray = faces.toArray();
for (int i = 0; i <facesArray.length; i++)
Imgproc.rectangle(aInputFrame, facesArray[i].tl(), facesArray[i].br(), new Scalar(0, 255, 0, 255), 3);
return aInputFrame;
}
@Override
public void onResume() {
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
}
}
导入我的代码中(在我之前的机器中可以解决)。但是,该项目可以正常运行并在模拟器上运行。但是由于侦听器无法解析,所以我无法进一步编写与Firebase相关的代码。
我尝试清理项目,重建,使缓存无效,但仍然没有运气。
等级依赖
OnSuccessListener
答案 0 :(得分:0)
请尝试将其添加到您的应用程序等级文件中。
实现'com.google.android.gms:play-services-tasks:16.0.1'
答案 1 :(得分:-1)
您要做的是使所有firebase和gms版本都具有相同的编号,例如:
实施'com.google.firebase:firebase-auth:102.0' 实施'com.google.android.gms:play-services-auth:10.2.0'