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

Providing SimpleCamera2Activity and VisualizeCamera2Activity as Fragments #154

Open
eschoenawa opened this issue Mar 2, 2020 · 9 comments
Labels

Comments

@eschoenawa
Copy link

Providing these two activities as Fragments would greatly increase the usability of these premade visualisation components. It would allow developers to include them in existing activities. If you still only want an activity you could then create one containing just the fragment.

@lessthanoptimal
Copy link
Owner

This design made sense years ago but is definitely out of date now. It could be a bit before I personally have time to convert it into a fragment and other modern Android features. If someone sees this issue and would like to submit a PR that would be great!

@lessthanoptimal lessthanoptimal changed the title [Feature Request] Providing SimpleCamera2Activity and VisualizeCamera2Activity as Fragments Providing SimpleCamera2Activity and VisualizeCamera2Activity as Fragments Mar 4, 2020
@hurzl
Copy link

hurzl commented Mar 15, 2020

Is it correct that I can't switch on torch mode in any subclass because the CaptureRequest.Builder mPreviewRequestBuilder and CameraOpen open etc. are private in SimpleCamera2Activity? Do I have to rewrite everything?
AFAIK I have to do sth. like
mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH) to switch on the flashlight.

... I found out how to overwrite configureCamera and call changeCameraConfiguration

@eschoenawa
Copy link
Author

@hurzl For next time try either creating a new issue or ask somewhere else, as this issue is about something completely different. Might also help others, who later have the same problem you had, to find the solution if it is located in a fitting issue and not just somewhere. ;)

@vogthenn
Copy link

This issue could probably be resolved easily with 'androidx.camera:camera-*', boofcv.android.ConvertBitmap. Using the ImageAnalyzer, you can use a PreviewView to point the camera, and analyze the images ConvertBitmap and qrCodePreciseDetector.detect(boofImage)
qrCodePreciseDetector.detector.detections would have the detection results

I might be able to provide a sample, not sure where to put it, though.

@lessthanoptimal
Copy link
Owner

@vogthenn Maybe as an example?

@lessthanoptimal
Copy link
Owner

Won't make it into the next stable release but the one after this should have a complete rewrite using fragments. Writing the code for a commercial project and after it's stabilized I'm planning on donating it to this project. Will probably be a couple of months before it works its way into BoofCV.

@lessthanoptimal
Copy link
Owner

Code seems to be able now. Copied the main class over and running into issues where I think some dependencies might be aar files only, which a Java project wouldn't like.

https://github.com/lessthanoptimal/BoofCV/tree/feature/fragments

That's the branch if anyone wants to try to help debug this build issue. Maybe the solution is to switch over to the Android plugin?

@lessthanoptimal
Copy link
Owner

'./gradlew assemble' spews out a bunch of errors that look like this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':integration:boofcv-android:compileKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':integration:boofcv-android:compileKotlin'
   > Could not resolve all files for configuration ':integration:boofcv-android:compileClasspath'.
      > Could not resolve androidx.core:core-ktx:1.9.0.
        Required by:
            project :integration:boofcv-android
         > No matching variant of androidx.core:core-ktx:1.9.0 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
             - Variant 'releaseVariantReleaseApiPublication' capability androidx.core:core-ktx:1.9.0 declares an API of a library, and its dependencies declared externally:
                 - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 11)
                     - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
             - Variant 'releaseVariantReleaseRuntimePublication' capability androidx.core:core-ktx:1.9.0 declares a runtime of a library, and its dependencies declared externally:
                 - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 11)
                     - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
             - Variant 'sourcesElements' capability androidx.core:core-ktx:1.9.0 declares a runtime of a component, and its dependencies declared externally:
                 - Incompatible because this component declares documentation and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                     - Doesn't say anything about its target Java version (required compatibility with Java 11)
                     - Doesn't say anything about its elements (required them preferably in the form of class files)
                     - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

@lessthanoptimal
Copy link
Owner

Good news! With help from @MaxDoss3 it appears to be building now. Going to try integrating it into a project and see if everything works as expected.

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

4 participants