Skip to content

Commit

Permalink
Merge pull request #1 from weareyipyip/feature/CBFA-57
Browse files Browse the repository at this point in the history
Feature/CBFA-57 -> master
  • Loading branch information
rvanderlinden authored Feb 1, 2024
2 parents 4aa84f3 + 43c8126 commit 07bcd00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ class DocumentScannerActivity : AppCompatActivity() {
}

// get bitmap from photo file path
val photo: Bitmap = ImageUtil().getImageFromFilePath(originalPhotoPath, maxContentSize)
val photo: Bitmap = try {
ImageUtil().getImageFromFilePath(originalPhotoPath, maxContentSize) ?: throw Exception("getImageFromFilePath did not return a bitmap.")
} catch (exception: Exception) {
finishIntentWithError(
"unable to get bitmap from photo file path: ${exception.message}"
)
return@CameraUtil
}

// get document corners by detecting them, or falling back to photo corners with
// slight margin if we can't find the corners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ImageUtil {
* @param maxContentSize used to limit the image size
* @return image bitmap
*/
fun getImageFromFilePath(filePath: String, maxContentSize: Int): Bitmap {
fun getImageFromFilePath(filePath: String, maxContentSize: Int): Bitmap? {
// read image as matrix using OpenCV
val image: Mat = this.getImageMatrixFromFilePath(filePath, maxContentSize)

Expand Down

0 comments on commit 07bcd00

Please sign in to comment.