Image overlayed five consecutive times on a live video

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SandhyaBK
    New Member
    • Nov 2012
    • 2

    Image overlayed five consecutive times on a live video

    Hi,

    I m trying to overlay an image on a live video.I have used alpha blending method to overlay image on the video. On overlaying the image, it gets overlayed five times rather than one as expected.

    Both frame data and the image data is taken as BYTE* for overlaying and displaying it.

    The image used is a bitmap image.

    The data (BYTE*) of both the video and the image is overlayed and the resultant is stored back in the variable of the video and den drawn on the picture control of vc++.


    The video resolution is 640x480.
    The image I m overlaying is 128x128.

    The IDE used is visual studio professional.Th e code is developed using c++.

    How do I overlay the bitmap image as a single image on the live video at a specific position.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It would help to see the code.

    Comment

    • SandhyaBK
      New Member
      • Nov 2012
      • 2

      #3
      Code:
      BYTE* VideoImage;//video data
      BYTE *BitmapData;//Bitmap data which has to be overlayed
      
      These two are being passed from a function.
      
      unsigned long cbImage;//Video size
      LONG BitmapImageSize; // Image size
      
      
      for(int i_bmp=0;i_bmp < BitmapImageSize;i_bmp+=4)
      			{
      			R1 = VideoImage[i_bmp+0];
      			G1 = VideoImage[i_bmp+1];
      			B1 = VideoImage[i_bmp+2];
                  Alpha1 = VideoImage[i_bmp+3];
      	
      			R2 = BitmapData[i_bmp+0];
                  G2 = BitmapData[i_bmp+1];
                  B2 = BitmapData[i_bmp+2];
                  Alpha2 = BitmapData[i_bmp+3];
      			
      			 R = (R1*Alpha1 + R2*(255 - Alpha1)) / 255;
      			 G = (G1* Alpha1+ G2*(255 - Alpha1)) / 255;
      			 B = (B1*Alpha1 + B2*(255 - Alpha1)) / 255;
      			 Alpha = min(Alpha1 + Alpha2, 255);
      
      
      	VideoImage[i_bmp+0] = static_cast<BYTE >(floor(0.5f + B));
      			VideoImage[i_bmp+1] = static_cast<BYTE >(floor(0.5f + G));
      			VideoImage[i_bmp+2] = static_cast<BYTE >(floor(0.5f + R));
      			VideoImage[i_bmp+3] = static_cast<BYTE >(floor(0.5f + 255.0f*Alpha));
      
      			}
      			
      hr = m_pBitmap->CopyFromMemory(NULL, 
      VideoImage,m_sourceStride);
      
      DrawBitmap(m_pBitmap);
      This is the codce..
      What happens here is that the image is getting overlayed.But it happens five times raher than one.
      Last edited by Rabbit; Dec 1 '12, 04:09 AM. Reason: Please use code tags when posting code.

      Comment

      Working...