Overview
RealWear’s My Camera provides two default solutions for 3rd party apps to open My Camera, capture an image and return the image to the calling app.
NOTE, when a thermal module is connected:
OPTION 1 will return a bitmap thermal image without Radiometric data.
OPTION 2 will save a FLIR Radiometric Thermal jpg at the URI provided by the 3rd party app.
Required Manifest Permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Use-cases
-
OPTION 1, Developers looking to capture an image and have a bitmap returned to display to the user.
-
OPTION 2, Developers trying to capture an image and get the full high resolution image saved to a specific file location(URI) with a specific name.
Image Capture
Overview
-
OPTION 1
-
3rd party app will use an image capture action intent to open the RealWear My Camera app
-
take a photo
-
In the returned activity result intent will be an extra where it’s key will be data and it’s value will be a bitmap image:
-
The return intent will have a bitmap for the calling application to return
-
-
-
OPTION 2
-
The 3rd party will define a URI with the expected:
-
MIME_TYPE = “image/jpg”
-
NAME = “my_photo.jpg”
-
and the relative path to this URI
-
-
use an image capture intent to open the RealWear My Camera app and attach the URI defined above to the extra key MediaStore.EXTRA_OUTPUT
-
take a photo
-
In the returned activity result intent will be an extras key MediaStore.EXTRA_OUTPUT with the same URI defined by the 3rd party app
-
Code Example
OPTION 1 (Bitmap)
-
3rd party call to My Camera app:
val cameraRequestCode: Int = 1337
val imageCaptureIntent: Intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(imageCaptureIntent, requestCode)
} -
Activity Result:
if (resultCode == Activity.RESULT_OK && requestCode == cameraRequestCode){
data?.let { cameraIntent ->
cameraIntent.extras?.get("data")?.let { imageFromCamera ->
findViewById(R.id.imageView).setBitmapImage(imageFromCamera)
}
}
}
}
OPTION 2 (Image URI)
-
3rd party call to My Camera app:
val thermalContentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, "my_photo.jpg")
put(MediaStore.MediaColumns.MIME_TYPE, "image/jpg")
put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM) 7 }
val thermalContentUri = baseContext.contentResolver.insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
thermalContentValues
)
val cameraRequestCode: Int = 1337
val imageCaptureIntent: Intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE).apply {
addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
putExtra(MediaStore.EXTRA_OUTPUT, thermalContentUri)
}
startActivityForResult(imageCaptureIntent, cameraRequestCode)
}Activity Result:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK && requestCode == cameraRequestCode) {
data?.let { cameraIntent ->
val imageUri = cameraIntent.data as? Uri
imageUri?.also { findViewById(R.id.imageView).setImageUri(it)}
}
}
super.onActivityResult(requestCode, resultCode, data)
}