Android Question Camera image bytes

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi to all. Is there a way to access the bytes of the camera to apply image processing techniques? My idea is to process the video frames. Thanks in advance.
 

wonder

Expert
Licensed User
Longtime User
+1
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Hi to all. Is there a way to access the bytes of the camera to apply image processing techniques? My idea is to process the video frames. Thanks in advance.
Did you mean the preview video or while recording?
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
No. A native c lib converts the preview data byte to Bitmap. And the mirror, invert and toning functions are also part of this c lib.
The functions are optimized for speed. Hardware acceleration or OpenGL are not involved.
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Like this, right?
B4X:
...
  LOGD("reading bitmap info...");
  AndroidBitmapInfo info;
  int ret;
  if ((ret = AndroidBitmap_getInfo(env, bitmap, & info)) < 0) {
      LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
      return NULL;
  }
  LOGD("width:%d height:%d stride:%d", info.width, info.height, info.stride);
  if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
      LOGE("Bitmap format is not RGBA_8888!");
      return NULL;
  }
  //
  //read pixels of bitmap into native memory :
  //
  LOGD("reading bitmap pixels...");
  void * bitmapPixels;
  if ((ret = AndroidBitmap_lockPixels(env, bitmap, & bitmapPixels)) < 0) {
      LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
      return NULL;
  }
  uint32_t * src = (uint32_t * ) bitmapPixels;
  uint32_t * tempPixels = new uint32_t[info.height * info.width];
  int stride = info.stride;
  int pixelsCount = info.height * info.width;
  memcpy(tempPixels, src, sizeof(uint32_t) * pixelsCount);
  AndroidBitmap_unlockPixels(env, bitmap);
...
(from StackOverflow)
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi. Yes, the idea is to get the frames of a video to process the images. From your discussion I see that it is necessary to use Android programming, not only B4A.
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I tested the App you posted. It works and, seeing that it processes the image in real time, I can consider the option to acquire your program, if it can work as a lib for B4A.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
I tested the App you posted. It works and, seeing that it processes the image in real time, I can consider the option to acquire your program, if it can work as a lib for B4A.
The needed functions are part of my MFLib version 2. It's not complete finished yet, but in two or three weeks i will publish it (with a lot other goodies) as donationware.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Feasible? yes.
But face detection is a very complex theme, in the medium term i don't have time for such a project.
Among many other projects (outside of Android/B4A) i have to finalize my MFLib. In the next months the lib will be extended with a motion detection module. And at last some of my apps should get ready for play store this year.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
MaFu, is it feasible to write a face detection algorithm in C++?
That would be a great addition to you library! :)
Did you mean in this way?
FaceDetect.jpg
 
Upvote 0
Top