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

External camera Android #164

Open
MrApple100 opened this issue Jul 7, 2023 · 6 comments
Open

External camera Android #164

MrApple100 opened this issue Jul 7, 2023 · 6 comments
Labels
support This is a support request.

Comments

@MrApple100
Copy link

I have a problem when using an external Epson bt35 e camera. There is a code that captures and sends a frame in ByteArray format. i want to use frame to ARTracking2d. But I don't really understand what needs to be changed in the program. I See a r w Android Video Puss In it but I'm not sure if this is the right function. Tell me, please, is it theoretically possible to use a frame from an external camera, or maybe you have some kind of program?

@philip-lamb
Copy link
Member

Hi, if I understand correctly, this is an external camera supported by other Android camera apps? If so, it might be as simple as requesting the external camera in the configuration. I've listed the options here: https://github.com/artoolkitx/artoolkitx/wiki/artoolkitX-video-module-configuration-reference#ar_video_module_android. If the camera correctly registers itself as external, you might be able to connect to it by using video config string of -module=Android -native -position=external. See https://github.com/artoolkitx/artoolkitx/wiki/artoolkitX-video-module-configuration-reference#changing-video-configuration for details on how to change the video configuration in your app.

@philip-lamb philip-lamb added the support This is a support request. label Jul 9, 2023
@MrApple100
Copy link
Author

MrApple100 commented Jul 9, 2023

Hi, the device was not recognized as an external camera (((. It only have function
override fun onCaptureData(timestamp: Long, bytes: ByteArray)
where I can get a frame and send it to artoolkitx

@philip-lamb
Copy link
Member

Ah, so if the camera interface is via java methods, you'll need to manually feed the frames to the native side. The new videoExternal module supports this. I can help some more from mid-next week.

@MrApple100
Copy link
Author

Hi, i'm back. May you describe a way to use external camera?

@MrApple100
Copy link
Author

@philip-lamb

@philip-lamb
Copy link
Member

I don't see anything in the Moverio SDK docs on the format of the buffers returned, but I guess a reasonable guess would be that they're NV21 format.

Since you will need to pass the video frames to artoolkitX externally, you will need to make a couple of changes in ARController.java's start() method.

At https://github.com/artoolkitx/artoolkitx/blob/master/Source/ARXJ/ARXJProj/arxj/src/main/java/org/artoolkitx/arx/arxj/ARController.java#L141, change it to arwStartRunning("-module=External", cameraParaPath), and then add an extra line: ARX_jni.arwVideoPushInit(0, width, height, "NV21", 0, 0);

You'll need to use the CaptureDataCallback2 type:

mCaptureDataCallback = new CaptureDataCallback2() {
							@Override
							public void onCaptureData(long timestamp, byte[] data) {
							    ARX_jni.arwVideoPush(0,
							        data, data.limit(), 0, 0, // OK to provide 0 for strides when using NV21.
							        null, 0, 0, 0,
								null, 0, 0, 0,
							        null, 0, 0, 0);
						        }
						    };

Also, you must call ARX_jni.arwVideoPushFinal() before calling arwVideoStop

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

No branches or pull requests

2 participants