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

Incompatibility with Fotoapparat 2.1.2 #17

Open
victor5171 opened this issue Jan 19, 2018 · 8 comments
Open

Incompatibility with Fotoapparat 2.1.2 #17

victor5171 opened this issue Jan 19, 2018 · 8 comments
Labels

Comments

@victor5171
Copy link

victor5171 commented Jan 19, 2018

Hi!

I'm trying to couple FaceDetector to Fotoapparat but it looks like the newest version of it is incompatible with FaceDetector.

The following code is used to startup the camera and the detector:

val faceDetectorProcessor = FaceDetectorProcessor.with(this).listener { rectanglesView.setRectangles(it) }.build()

fotoApparat = Fotoapparat.with(this) .into(cameraView) .frameProcessor { faceDetectorProcessor.processFrame(it) } .build()

As you can see, the FrameProcessor property is now a lambda, so i've adapted the call.

But i'm receiving the following error (the application is crashing) if i run this code:

E/AndroidRuntime: FATAL EXCEPTION: pool-10-thread-1 Process: br.com.esapiens.ysos, PID: 17567 java.lang.IllegalAccessError: Field 'io.fotoapparat.preview.Frame.image' is inaccessible to class 'io.fotoapparat.facedetector.processor.FaceDetectorProcessor' (declaration of 'io.fotoapparat.facedetector.processor.FaceDetectorProcessor' appears in /data/app/br.com.esapiens.ysos-1/split_lib_dependencies_apk.apk) at io.fotoapparat.facedetector.processor.FaceDetectorProcessor.processFrame(FaceDetectorProcessor.java:37) at br.com.esapiens.ysos.camera.CameraActivity$onCreate$1.invoke(CameraActivity.kt:27) at br.com.esapiens.ysos.camera.CameraActivity$onCreate$1.invoke(CameraActivity.kt:11) at io.fotoapparat.preview.PreviewStream.dispatchFrame(PreviewStream.kt:92) at io.fotoapparat.preview.PreviewStream.access$dispatchFrame(PreviewStream.kt:14) at io.fotoapparat.preview.PreviewStream$dispatchFrameOnBackgroundThread$1.run(PreviewStream.kt:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

@Diolor Diolor added the bug label Jan 19, 2018
@Diolor
Copy link
Member

Diolor commented Jan 19, 2018

Thanks @victor5171.
Let's think if @dmitry-zaitsev if we want the 2 libraries version independent or coupled.

@ghost
Copy link

ghost commented Jan 29, 2018

any solution for this problem?

@Diolor
Copy link
Member

Diolor commented Feb 2, 2018

Can you please try FA 2.2.0? Curious why image field is not accessible.

@predasorinionut
Copy link

Hi!

I'm having the same problem as @victor5171 with FA 2.2.0 and FD 1.0.0.
Any idea about a solution @Diolor ?

@ghost
Copy link

ghost commented Feb 8, 2018

This is the exception I get :
FATAL EXCEPTION: pool-4-thread-1
java.lang.AbstractMethodError: abstract method "void io.fotoapparat.preview.FrameProcessor.process(io.fotoapparat.preview.Frame)"
at io.fotoapparat.FotoapparatBuilder$frameProcessor$$inlined$apply$lambda$1.invoke(FotoapparatBuilder.kt:125)
at io.fotoapparat.FotoapparatBuilder$frameProcessor$$inlined$apply$lambda$1.invoke(FotoapparatBuilder.kt:19)
at io.fotoapparat.preview.PreviewStream.dispatchFrame(PreviewStream.kt:107)
at io.fotoapparat.preview.PreviewStream.access$dispatchFrame(PreviewStream.kt:16)
at io.fotoapparat.preview.PreviewStream$dispatchFrameOnBackgroundThread$1.run(PreviewStream.kt:92)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)f

@RationalRank
Copy link

Hey @Kim24 . I do get the same exception. Any heads up on it?

@joelhaasnoot
Copy link

joelhaasnoot commented Mar 6, 2018

I have a solution in the mean time, write your frame processor like this

frameProcessor = { val faces = faceDetector.detectFaces(it.image, it.size.width, it.size.height, it.rotation)
                                runOnUiThread {
                                    rectangles?.setRectangles(faces)
                                }
                            })

where faceDetector is

val faceDetector = FaceDetector.create(this)

In this way you essentially recreate FaceDetectorProcessor as a lambda function.

@scognito
Copy link

scognito commented Jan 3, 2019

Following @joelhaasnoot advice, here it is the Java version:

private class CustomFrameProcessor implements FrameProcessor {
    @Override
    public void process(@NotNull Frame frame) {

        List<Rectangle> faces = faceDetector.detectFaces(frame.getImage(), frame.getSize().width, frame.getSize().height, frame.getRotation());
        runOnUiThread(() -> rectanglesView.setRectangles(faces));
    }
}

FaceDetector faceDetector = FaceDetector.create(this);
CustomFrameProcessor processor = new CustomFrameProcessor();

fotoapparat = Fotoapparat.with(this)
			.frameProcessor(processor)
			...

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

No branches or pull requests

6 participants