Android Question getPixel from Panel

Jose A. Vazquez

New Member
Licensed User
Hi everybody,

I'm absolutely new in Android prog. and of course in B4A, so although I have been searching into the forums with no success it's possible that the answer be quite simple.
I´m trying to build a barcode scanner as a part of a major project, only ean13 codes are needed, I have done the same in other languages. Of course I know that exists libraries like Zxing and others, but they are too big for what I need.
My question is,
Using camera2 library and once the camera its playing into a panel how can I read a pixel.
I wouldn't like to copy the entire panel into a canvas to do it, because the system must work in real time.
Can I implement in anyway a getPixel into the panel, adding a view on it ???
Can I copy a clip as a part of the panel into a buffer in with read each pixel ???
I will appreciate any help,

thanks
Jose A
 

JordiCP

Expert
Licensed User
Longtime User
Hi Jose,

In the camera preview mode (real time, no picture taken) , you don't have easy access to the panel's content, since it is controlled by the same camera.

But, if you activate the preview interrupt, then you will have the preview data passed as an argument. It is in YUV format, where first you have the luminance info, and then color info. As for a barcode scanner you need luminance, it will fit your purposes.

Look at this similar thread, perhaps this helps:


(Edit)
Also, this post can be useful to understand YUV format ;)

 
Upvote 0

Jose A. Vazquez

New Member
Licensed User
For the first link, I understand the code; it receives the image (YUV) into the data() array and it reads the central line of pixels, but how can I "activate the preview interrupt", do you mean that I must to invoke the method StopPreview of the camera object?
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Not exactly. When you initialize the camera you have an option to declare a Sub which will be called automatically each time the camera has a preview image (this will happen several times per second)

In this routine, you can do your own processing. Or, if you don't need to do it each time, you can do it once every N calls to the event.

I would start with cameraEx class which also has a working example. Look for the "Sub Camera1_Preview (PreviewPic() As Byte)" in the main module

https://www.b4x.com/android/forum/t...e-camera-library-functionality.23801/#content
 
Upvote 0
Top