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

Record video (in my own code) while VisionManager is running #260

Open
billylo1 opened this issue Nov 19, 2020 · 4 comments
Open

Record video (in my own code) while VisionManager is running #260

billylo1 opened this issue Nov 19, 2020 · 4 comments

Comments

@billylo1
Copy link

billylo1 commented Nov 19, 2020

Given the VisionManager.startRecording is for debugging only, I am trying to find a simple way to record the video using my own code.

I used Google's Camera2 video recorder sample as starting point. https://github.com/googlearchive/android-Camera2Video

And then add the VisionManager start into onResume().

The result is somewhat strange... it seems to work initially, but after 5 minutes. The app crashes with this in logcat.

Any hints on how to do my own video recording?

thanks,

2020-11-18 23:40:43.768 31462-31703/com.katlalabs.sidekick I/MediaCodec: (0x797a890200) start
2020-11-18 23:40:43.784 31462-847/com.katlalabs.sidekick I/MediaCodec: (0x797a890200) kWhatStartCompleted
2020-11-18 23:40:43.793 31462-31703/com.katlalabs.sidekick E/AndroidRuntime: FATAL EXCEPTION: RecorderThread
    Process: com.katlalabs.sidekick, PID: 31462
    java.lang.RuntimeException: Error loading texture.
        at com.mapbox.vision.utils.GlUtils.createTexture(GlUtils.kt:197)
        at com.mapbox.vision.gl.GLBackgroundFrame.createTexture(GLBackgroundFrame.kt:29)
        at com.mapbox.vision.video.videosource.recording.MediaEncoderWrapper.<init>(MediaEncoderWrapper.kt:82)
        at com.mapbox.vision.video.videosource.recording.Camera2VideoSourceRecorderImpl.initEncoderWrapper(Camera2VideoSourceRecorderImpl.kt:28)
        at com.mapbox.vision.video.videosource.recording.Camera2VideoSourceRecorderImpl.access$initEncoderWrapper(Camera2VideoSourceRecorderImpl.kt:7)
        at com.mapbox.vision.video.videosource.recording.Camera2VideoSourceRecorderImpl$startRecording$1.invoke(Camera2VideoSourceRecorderImpl.kt:69)
        at com.mapbox.vision.video.videosource.recording.Camera2VideoSourceRecorderImpl$startRecording$1.invoke(Camera2VideoSourceRecorderImpl.kt:7)
        at com.mapbox.vision.utils.threads.WorkThreadHandler$post$1.run(WorkThreadHandler.kt:19)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:241)
        at android.os.HandlerThread.run(HandlerThread.java:67)
@yunikkk
Copy link
Collaborator

yunikkk commented Dec 11, 2020

Hey @billylo1, is the question still relevant?
At the moment we don't have simple way to record video aside from startRecording.
The Google's Camera2 video recorder app open's camera inside, and we also open camera in Vision, so I guess it have a lot of conflicts and isn't going to work stable anyway. Could you describe your use case more?

@billylo1
Copy link
Author

Hi, This is what I built for iOS. sidekick-app.com. Mapbox vision can coexist with standard camera api there... hoping to do the same thing on Android.

@Cosxin
Copy link

Cosxin commented Jan 21, 2021

I had the same issue and I found a walkaround. Since you have your own recording I am assuming you have a previewView sort of thing. So instead of creating the VisionManager and attaching it to the camera, you can attach it to a customVideoSource VisionManager.create(customVideoSource) and from the customVideoSource you fetch the bitmap from your previewView on a fixed timed interval (To do this you need to post message to UIThread).

This allows you to decouple the detection fps from the UI fps.

@billylo1
Copy link
Author

thanks! Let me give it a try.

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

3 participants