| 59 | } |
| 60 | |
| 61 | std::vector<ScanResult> |
| 62 | DecodeScheduler::readByte(jbyte* bytes, int width, int height) |
| 63 | { |
| 64 | LockGuard locker { m_decodeLock }; |
| 65 | LOGE("start readByte rowWidth = %d rowHeight = %d", width, height) |
| 66 | |
| 67 | cv::Mat src(height + height / 2, width, CV_8UC1, bytes); |
| 68 | saveMat(src); |
| 69 | |
| 70 | // 转灰并更改格式 |
| 71 | cv::Mat gray; |
| 72 | cvtColor(src, gray, cv::COLOR_YUV2GRAY_NV21); |
| 73 | saveMat(gray, "gray"); |
| 74 | |
| 75 | // 顺时针旋转90度图片,得到正常的图片(Android的后置摄像头获取的格式是横着的,需要旋转90度) |
| 76 | rotate(gray, gray, cv::ROTATE_90_CLOCKWISE); |
| 77 | |
| 78 | LOGE("end readByte rowWidth = %d rowHeight = %d", width, height) |
| 79 | return startDecode(gray); |
| 80 | } |
| 81 | |
| 82 | std::vector<ScanResult> DecodeScheduler::readBitmap(JNIEnv* env, jobject bitmap) |
| 83 | { |
no test coverage detected