Skip to content

Commit c9aa44d

Browse files
committed
Merge branch 'master' into android_ds_7.1.1
2 parents 2943c47 + fe28b1d commit c9aa44d

File tree

1 file changed

+46
-0
lines changed
  • data-capture-ready-to-use-ui-example/app/src/main/java/io/scanbot/example/doc_code_snippet/detailed_setup_guide

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.scanbot.example.doc_code_snippet.detailed_setup_guide
2+
3+
import io.scanbot.sdk.camera.CameraViewType
4+
import io.scanbot.sdk.camera.MockCameraResourceProvider
5+
import io.scanbot.sdk.camera.ScanbotCameraViewConfigurationProvider
6+
7+
class MockCameraSnippet {
8+
// @Tag("Mock Camera Initialization")
9+
/*
10+
* Initializes the Camera with a mock camera configuration.
11+
* This is useful for testing purposes without requiring a physical camera.
12+
*
13+
* The mock camera will display a static image as the camera feed.
14+
* Make sure to replace the image path with a valid one in your project.
15+
*
16+
* `MockCameraResourceProvider` - delegate that used for feeding camera with fake frames.
17+
* `getFrameImagePath()` - should return path to the absolute path to the `File` in format without `file://` schema and will be used as detection frame.
18+
* `getCapturedImagePath()` - should return path to the absolute path to the `File` in format without `file://` schema and will be used as captured image.
19+
* `showDebugImage` - if true, the mock camera will show `getFrameImagePath` file as image preview.
20+
* `tryHideFinderView` - if true, the finder view will be hidden.
21+
* `tryHidePolygonView` - if true, the ar overlay polygon view will be hidden.
22+
* `delayBetweenFramesMs` - delay between frames in milliseconds, used to simulate a camera feed.
23+
* `forceImageUploadOnSamePath` - if true, the mock camera will reload the image from the file system even if the path has not changed. This is useful for testing scenarios where the image file might be updated.
24+
* `imageFileReadAttemptLimit` - the number of attempts to read the image file. Helps to handle cases where the file might not be immediately available.
25+
* `imageFileReadAttemptDelay` - delay between attempts to read the image file. Helps to avoid busy-waiting and allows the file system to stabilize if the file is being written to.
26+
*/
27+
fun initMockCamera() {
28+
ScanbotCameraViewConfigurationProvider.cameraViewType =
29+
CameraViewType.Mock(
30+
resourceProvider = object : MockCameraResourceProvider {
31+
override fun getFrameImagePath(): String {
32+
return "/data/data/io.scanbot.example.sdk.rtu.android/files/test.png"
33+
}
34+
35+
override fun getCapturedImagePath(): String? {
36+
return "/data/data/io.scanbot.example.sdk.rtu.android/files/test.png"
37+
}
38+
},
39+
showDebugImage = true,
40+
tryHideFinderView = false,
41+
tryHidePolygonView = false,
42+
delayBetweenFramesMs = 100L
43+
)
44+
}
45+
// @EndTag("Mock Camera Initialization")
46+
}

0 commit comments

Comments
 (0)