Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera view is black, no video preview and no faces are detected #44

Open
Zaniyar opened this issue Nov 5, 2020 · 0 comments
Open

Camera view is black, no video preview and no faces are detected #44

Zaniyar opened this issue Nov 5, 2020 · 0 comments

Comments

@Zaniyar
Copy link

Zaniyar commented Nov 5, 2020

I am using FotoApparat in my App.
When I try to implement the facedetector the Camera View stays black. Nothing to see.

app/build.gradle:

    implementation 'io.fotoapparat:facedetector:1.0.0'
    implementation 'io.fotoapparat:fotoapparat:2.7.0'

MainActivity.kt:


    override fun onCreate(savedInstanceState: Bundle?) {
            ...
        createFotoapparat()
           ...
     }

    private fun createFotoapparat(){
        val cameraView = findViewById<CameraView>(R.id.cameraView)
        fotoapparat = Fotoapparat(
            context = this,
            view = cameraView,
            scaleType = ScaleType.CenterCrop,
            lensPosition = back(),
            logger = loggers(
                logcat()
            ),
            cameraErrorCallback = { error ->
                println("Recorder errors: $error")
            }
        ) 
        // now the processor - when I delete this and also the layouts in the view, Camera preview is visible again
        val processor = FaceDetectorProcessor.with(this)
            .listener({ faces ->
                rectanglesView.setRectangles(faces)  // (Optional) Show detected faces on the view.
                Log.v("Faces",faces.toString());   // is never called!
                // ... or do whatever you want with the result
            })
            .build()

        Fotoapparat.with(this)
            .into(cameraView)
            // the rest of configuration
            .frameProcessor(processor)
            .build()

    }

activity_main.xml:


    <io.fotoapparat.facedetector.view.CameraOverlayLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <!-- Adjust parameters as you like. But cameraView has to be inside CameraOverlayLayout -->
        <io.fotoapparat.view.CameraView
                android:id="@+id/cameraView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        <!-- This view will display detected faces -->
        <io.fotoapparat.facedetector.view.RectanglesView
                android:id="@+id/rectanglesView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:rectanglesColor="@color/colorAccent"
                app:rectanglesStrokeWidth="2dp"/>

    </io.fotoapparat.facedetector.view.CameraOverlayLayout>

I don't get any errors, but I don't see anything. No faces, no camera preview stream.

...

When I add this line, I get the error (I am not sure if this is needed, when I already io.fotoapparat:fotoapparat:2.7.0) :

ERROR: Failed to resolve: io.fotoapparat.fotoapparat:library:1.0.0

for:

    // If you are using Fotoapparat add this one as well
    implementation 'io.fotoapparat.fotoapparat:library:1.2.0' // or later version 

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant