Forums - Problem with fcvColor Functions

9 posts / 0 new
Last post
Problem with fcvColor Functions
Panayiotish
Join Date: 15 May 12
Posts: 10
Posted: Sat, 2013-02-23 03:44

Hello to all!!

I am trying to extend the FastCV corner detection sample in order to integrate OpenCV in it to combine the two libraries.

My philosophy is to keep the exact same code as to the point of fcvColorYUV420toRGB565u8 is being used where the YUV image from android is being converter to RGB565 in ordered to be proceced. From that far and beyond I will use both FastCV and OpenCV functions in order to achieve my result.

The thing I want to do with OpenCV recquires RGB888 images instead of RGB565. So I decided to use the new function fcvColorRGB565ToRGB888u8 which is added in FastCV 1.2.0 in order to convert the RGB565 image to RGB888 once there isn't any YUV420 To RGB888 function (there is fcvColorYUV420toRGB8888u8 to convert it to RGB8888 but OpenCV does not read RGBA images so I would have to cut the A channel, and that is why I preferred the way described above).


The problem is that when I try to use two fcvColor functions concatenated (the one after the other) the application crushes without throwing any error that I could see what the problem is to fix it. I put the second fcvColor function exactly after the first one and the program crushes. I thought that maybe a problem would occur if I use the destination image of the first function as source image (pointers of data in fact) of the second function. So I created new variables 128 bit alligned and passed it into the second function and again the same happens. I have tried to use a second fcvColor function in another part of the code, another fcvColor function not the one described above, in order to see if that works and again the program crushes.

What seems to be the problem? I can't use two fcvColor functions the one afther the other? 


Panayiotis


 

  • Up0
  • Down0
jeff4s Moderator
Join Date: 4 Nov 12
Posts: 106
Posted: Mon, 2013-02-25 15:20

Hi,

If you can share your code snippet that caused the problem, it will help us investigate the issue more easily.

Thanks,

-Jeff

  • Up0
  • Down0
Panayiotish
Join Date: 15 May 12
Posts: 10
Posted: Mon, 2013-02-25 23:51

The code isn't something specific, I use exactly the same coce as the example and I add at the end of the first fcvColor the second one, outside of the loop. So:

 

 

JNIEXPORT void 
   JNICALL Java_com_qualcomm_fastcorner_FastCVSample_update
(
   JNIEnv*     env, 
   jobject     obj, 
   jbyteArray  img, 
   jint        w, 
   jint        h,
   jfloat* modelArray
)
   jbyte*            jimgData = NULL;
   jboolean          isCopy = 0;
   uint32_t*         curCornerPtr = 0;
   uint8_t*          renderBuffer;
   uint8_t*          rgb888Output;
   uint64_t          time;
   float             timeMs;

...
...
...
else
   {
      fcvColorYUV420toRGB565u8(
         pJimgData,
         w,
         h, 
         (uint32_t*)renderBuffer );
 
   }
 
// To this point the code is EXACTLY the same as the example. From now on I just add the next FcvColor
       fcvColorRGB565ToRGB888u8(
             renderBuffer,
              w,
              h,
              0,
              rgb888Output,
              0);
 
Let me clear that rgb888Output is 128-bit alligned.
 
 
 
 

 

 

  • Up0
  • Down0
Panayiotish
Join Date: 15 May 12
Posts: 10
Posted: Tue, 2013-02-26 00:39

I have also tried to use the second function with new arguments and again it crushes.

Now I have tried to use only the second fcvColor (from rgb565 to rgb888) without using the first one and again it crashes. Like the function has a problem...

Nevertheless, I have tried to use another fcvColor function (from YUV420 to rgb8888) by its own, without first using YUV420toRGB565 and it works. But when I combine two fcvColour functions it crushes.

  • Up0
  • Down0
my
Join Date: 6 Dec 12
Posts: 5
Posted: Tue, 2013-02-26 10:21

Hi,

Can you provide how renderBuffer and rgb888Output buffer are allocated as well as the w and h value?

Thanks.

 

 

 

  • Up0
  • Down0
my
Join Date: 6 Dec 12
Posts: 5
Posted: Tue, 2013-02-26 10:27

We are investigating fcvColorRGB565ToRGB888u8, meanwhile you may try another API fcvColorYCbCr420PseudoPlanarToRGB888u8 that converts YCbCr420 to RGB888 directly.

  • Up0
  • Down0
Panayiotish
Join Date: 15 May 12
Posts: 10
Posted: Wed, 2013-02-27 00:56

The w and h values are standard and are equal to 800 and 480 respectively (multiple of 8).

For the aligning and the allocation of the two buffers I use exactly the same method as is used with the jimgData:

 
if( (int)rgb888Output& 0xF )

 

   {
      // Allow for rescale if dimensions changed.
      if( w != (int)state.alignedImgWidth || 
          h != (int)state.alignedImgHeight )
      {
         if( state.alignedImgBuf != NULL )
         {
            DPRINTF( "%s %d Creating aligned for preview\n", 
               __FILE__, __LINE__ );
            fcvMemFree( state.alignedImgBuf );
            state.alignedImgBuf = NULL;
         }
      }
 
      // Allocate buffer for aligned data if necessary.
      if( state.alignedImgBuf == NULL )
      { 
         state.alignedImgWidth = w;
         state.alignedImgHeight = h;
         state.alignedImgBuf = (uint8_t*)fcvMemAlloc( w*h*3/2, 16 );
      }
 
      memcpy( state.alignedImgBuf, rgb888Output, w*h*3/2 );
      rgb888Output = state.alignedImgBuf;
   }
 
And the same with the renderBuffer.
  • Up0
  • Down0
my
Join Date: 6 Dec 12
Posts: 5
Posted: Wed, 2013-02-27 13:46

Thanks for the reply. But I did not see how the rgb888Output buffer is allocated. The code snippet is taking care of the alignment but that's not the concern. We need to see how big the buffers are.

You code snippet shows that the state.alignedImgBuf is of size w*h*3/2 and the data are copied over from rgb888Output. However, rgb888Output buffer size should be at least w * h * 3.

Another concern is that you modified the rgb888Output buffer address for alignment, did you have a copy of the original address?

  • Up0
  • Down0
my
Join Date: 6 Dec 12
Posts: 5
Posted: Mon, 2013-03-04 22:13

Just wanted to follow up with this issue. We tried many different sized images on fcvColorRGB565ToRGB888u8. No issue has been found. Would like to know if you have followed previous recommendations, and if you are still seeing any problem.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.