Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

android opencv 4.3.0 Assertion failed (buf.checkVector(1, CV_8U) > 0)

I am taking the image from android phone's camera and want to do some processing on it .

override fun onPictureTaken(p0: ByteArray?, p1: Camera?) { Log.i(TAG, "on picture taken") Observable.just(p0) .subscribeOn(proxySchedule) .subscribe { val pictureSize = p1?.parameters?.pictureSize Log.i(TAG, "picture size: " + pictureSize.toString()) Log.i(TAG, "on picture taken") Log.i(TAG, "picture size: w" + pictureSize?.width.toString()) Log.i(TAG, "picture size:h " + pictureSize?.height.toString()) val mat = Mat(Size(pictureSize?.width?.toDouble() ?: 1920.toDouble(), pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)

                    pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)
            Log.i(TAG, "on picture taken mat 1"+mat.toString())
            Log.i(TAG, "on picture taken p0"+p0?.size.toString())//not null
            mat.put(0, 0, p0)
            Log.i(TAG, "on picture taken mat 2"+mat.toString())//not null

            val pic = Imgcodecs.imdecode(mat, Imgcodecs.IMREAD_UNCHANGED)//error here

            Core.rotate(pic, pic, Core.ROTATE_90_CLOCKWISE)
            mat.release()
            SourceManager.corners = processPicture(pic)
            Imgproc.cvtColor(pic, pic, Imgproc.COLOR_RGB2GRAY)
            SourceManager.pic = pic
            context.startActivity(Intent(context, CropActivity::class.java))
            busy = false
        }

}

Below is the error E/cv::error(): OpenCV(4.3.0) Error: Assertion failed (buf.checkVector(1, CV_8U) > 0) in imdecode_, file /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp, line 755

E/org.opencv.imgcodecs: imgcodecs::imdecode_10() caught cv::Exception: OpenCV(4.3.0) /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp:755: error: (-215:Assertion failed) buf.checkVector(1, CV_8U) > 0 in function 'imdecode_'

click to hide/show revision 2
None

updated 2020-07-13 06:03:40 -0600

berak gravatar image

android opencv 4.3.0 Assertion failed (buf.checkVector(1, CV_8U) > 0)

I am taking the image from android phone's camera and want to do some processing on it .

override fun onPictureTaken(p0: ByteArray?, p1: Camera?) {
Log.i(TAG, "on picture taken")
Observable.just(p0)
.subscribeOn(proxySchedule)
.subscribe {
val pictureSize = p1?.parameters?.pictureSize
Log.i(TAG, "picture size: " + pictureSize.toString())
Log.i(TAG, "on picture taken")
Log.i(TAG, "picture size: w" + pictureSize?.width.toString())
Log.i(TAG, "picture size:h " + pictureSize?.height.toString())
val mat = Mat(Size(pictureSize?.width?.toDouble() ?: 1920.toDouble(),
pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)

CvType.CV_8U)
 pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)
  Log.i(TAG, "on picture taken mat 1"+mat.toString())
 Log.i(TAG, "on picture taken p0"+p0?.size.toString())//not null
 mat.put(0, 0, p0)
  Log.i(TAG, "on picture taken mat 2"+mat.toString())//not null
 val pic = Imgcodecs.imdecode(mat, Imgcodecs.IMREAD_UNCHANGED)//error here
 Core.rotate(pic, pic, Core.ROTATE_90_CLOCKWISE)
 mat.release()
  SourceManager.corners = processPicture(pic)
 Imgproc.cvtColor(pic, pic, Imgproc.COLOR_RGB2GRAY)
 SourceManager.pic = pic
 context.startActivity(Intent(context, CropActivity::class.java))
  busy = false
 }
}

}

Below is the error error

E/cv::error(): OpenCV(4.3.0) Error: Assertion failed (buf.checkVector(1, CV_8U) > 0) in imdecode_, file /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp, line 755

755 E/org.opencv.imgcodecs: imgcodecs::imdecode_10() caught cv::Exception: OpenCV(4.3.0) /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp:755: error: (-215:Assertion failed) buf.checkVector(1, CV_8U) > 0 in function 'imdecode_'

'imdecode_'

android opencv 4.3.0 Assertion failed (buf.checkVector(1, CV_8U) > 0)

I am taking the image from android phone's camera and want to do some processing on it .

override fun onPictureTaken(p0: ByteArray?, p1: Camera?) {
    Log.i(TAG, "on picture taken")
    Observable.just(p0)
            .subscribeOn(proxySchedule)
            .subscribe {
                val pictureSize = p1?.parameters?.pictureSize
                Log.i(TAG, "picture size: " + pictureSize.toString())
                Log.i(TAG, "on picture taken")
                Log.i(TAG, "picture size: w" + pictureSize?.width.toString())
                Log.i(TAG, "picture size:h " + pictureSize?.height.toString())
                    val mat = Mat(Size(pictureSize?.width?.toDouble() ?: 1920.toDouble(),
                           pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)

                        pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)
                 Log.i(TAG, "on picture taken mat 1"+mat.toString())
                Log.i(TAG, "on picture taken p0"+p0?.size.toString())//not null
                mat.put(0, 0, p0)
                Log.i(TAG, "on picture taken mat 2"+mat.toString())//not null

                val pic = Imgcodecs.imdecode(mat, Imgcodecs.IMREAD_UNCHANGED)//error here

                Core.rotate(pic, pic, Core.ROTATE_90_CLOCKWISE)
                mat.release()
                SourceManager.corners = processPicture(pic)
                Imgproc.cvtColor(pic, pic, Imgproc.COLOR_RGB2GRAY)
                SourceManager.pic = pic
                context.startActivity(Intent(context, CropActivity::class.java))
                busy = false
            }
}

Below is the error

E/cv::error(): OpenCV(4.3.0) Error: Assertion failed (buf.checkVector(1, CV_8U) > 0) in imdecode_, file /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp, line 755

E/org.opencv.imgcodecs: imgcodecs::imdecode_10() caught cv::Exception: OpenCV(4.3.0) /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp:755: error: (-215:Assertion failed) buf.checkVector(1, CV_8U) > 0 in function 'imdecode_'

android opencv 4.3.0 Assertion failed (buf.checkVector(1, CV_8U) > 0)

I am taking the image from android phone's camera and want to do some processing on it .

override fun onPictureTaken(p0: ByteArray?, p1: Camera?) {
    Log.i(TAG, "on picture taken")
    Observable.just(p0)
            .subscribeOn(proxySchedule)
            .subscribe {
                val pictureSize = p1?.parameters?.pictureSize
                Log.i(TAG, "picture size: " + pictureSize.toString())
                Log.i(TAG, "on picture taken")
                Log.i(TAG, "picture size: w" + pictureSize?.width.toString())
                Log.i(TAG, "picture size:h " + pictureSize?.height.toString())
                    val mat = Mat(Size(pictureSize?.width?.toDouble() ?: 1920.toDouble(),
                           pictureSize?.height?.toDouble() ?: 1080.toDouble()), CvType.CV_8U)


                Log.i(TAG, "on picture taken mat 1"+mat.toString())
                Log.i(TAG, "on picture taken p0"+p0?.size.toString())//not null
null//3049977
                mat.put(0, 0, p0)
                Log.i(TAG, "on picture taken mat 2"+mat.toString())//not null

                val pic = Imgcodecs.imdecode(mat, Imgcodecs.IMREAD_UNCHANGED)//error here

                Core.rotate(pic, pic, Core.ROTATE_90_CLOCKWISE)
                mat.release()
                SourceManager.corners = processPicture(pic)
                Imgproc.cvtColor(pic, pic, Imgproc.COLOR_RGB2GRAY)
                SourceManager.pic = pic
                context.startActivity(Intent(context, CropActivity::class.java))
                busy = false
            }
}

Below is the error

E/cv::error(): OpenCV(4.3.0) Error: Assertion failed (buf.checkVector(1, CV_8U) > 0) in imdecode_, file /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp, line 755

E/org.opencv.imgcodecs: imgcodecs::imdecode_10() caught cv::Exception: OpenCV(4.3.0) /build/master_pack-android/opencv/modules/imgcodecs/src/loadsave.cpp:755: error: (-215:Assertion failed) buf.checkVector(1, CV_8U) > 0 in function 'imdecode_'