0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-19 19:42:18 +02:00

Invert every second frame

Forgot to invert every second frame to also read inverted
barcodes while simplifying image processing.
This commit is contained in:
Markus Fisch 2017-09-03 12:26:49 +02:00
parent 3a650bc0cd
commit cbc0ff435f
2 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class YuvToGray(context: Context) {
private var rgbaAlloc: Allocation? = null
private var destAlloc: Allocation? = null
private var dest: Bitmap? = null
private var odd = true
fun destroy() {
yuvType?.destroy()
@ -76,7 +77,14 @@ class YuvToGray(context: Context) {
// width/height are uint_32 but Kotlin wants toLong()
yuv2grayScript._inWidth = width.toLong()
yuv2grayScript._inHeight = height.toLong()
yuv2grayScript.forEach_yuv2gray(rgbaAlloc)
// invert every second frame to also read inverted barcodes
if (odd) {
yuv2grayScript.forEach_yuv2gray(rgbaAlloc)
} else {
yuv2grayScript.forEach_yuv2inverted(rgbaAlloc)
}
odd = odd xor true
rotatorScript._inImage = rgbaAlloc
rotatorScript._inWidth = width

View File

@ -15,3 +15,13 @@ uchar4 RS_KERNEL yuv2gray(uint32_t x, uint32_t y) {
out.a = 255;
return out;
}
uchar4 RS_KERNEL yuv2inverted(uint32_t x, uint32_t y) {
uchar Y = 255 - rsGetElementAt_uchar(inYUV, x, y);
uchar4 out;
out.r = Y;
out.g = Y;
out.b = Y;
out.a = 255;
return out;
}