Ask Your Question

Engin's profile - activity

2015-03-19 07:45:26 -0600 received badge  Student (source)
2015-03-19 06:58:42 -0600 asked a question Decorationless Window - How??

Hello,

My display's resolution is 1920x1080. I want to show images which are size of 1920x1080 on this display. But window decorations (titlebar and borders) eat into my display area. How can I overcome this? What is the best way to go fully fullscreen?

Setting CV_WND_PROP_FULLSCREEN to CV_WINDOW_FULLSCREEN removes titlebar but borders remain. :(

2015-03-10 13:47:16 -0600 commented answer How to calculate the YUV values of a grayscale image ?

You are welcome.

2015-03-10 12:30:33 -0600 commented answer How to calculate the YUV values of a grayscale image ?

Yes it is.

2015-03-10 12:24:20 -0600 commented question Failing to display YUV image correctly

Old code is not mine and it is pretty large for me to convert from c to c++.

2015-03-10 12:12:53 -0600 received badge  Critic (source)
2015-03-10 12:12:46 -0600 answered a question How to calculate the YUV values of a grayscale image ?

An YUV image is composed of three channels: luminance/luma (Y/Y'), chroma blue (U), chroma red (V).

If your image is in YUV space and appears grayscale, it has no blue and red components, only luminance, zero blue and red components. Or if your image is in RGB space and grayscale, its R, G and B values are not too diverse, e.g. (R,G,B) = (120,115,123).

Conversion is done by:

image description

2015-03-10 07:44:38 -0600 commented question Failing to display YUV image correctly

I know, but I must use C-interface if I can. Because my code will be integrated with an old code. :(

Reason of error is, I think, cvResize(). When I shrink the Y component, merge with U and V, convert, I get correct colors then -but with a small sized image (320x240).

I think I need help with this cvResize() function.

2015-03-10 07:35:36 -0600 received badge  Editor (source)
2015-03-10 07:15:55 -0600 asked a question Failing to display YUV image correctly

Hello,

I am writing a program that must read from a 4:2:0 chroma subsampled yuv video file and display it on screen. Program is working but shows wrong colors. And I could not find where error is.

Picture I see:

Picture I see

Picture I must see:

Picture I must see

Unfortunately, I must use OpenCV 2.1 and C API (iplimage...).

My code:

int main()
{
    int iFrameWidth = 640;
    int iFrameHeight = 480;

    FILE *fYUV0 = fopen( "C:\\YUV_Videos\\flamenco2_0.yuv", "rb" );

    char *cFileBuffer0 = new char[ iFrameWidth*iFrameHeight*3/2 ];

    IplImage *iplY420Frame = cvCreateImageHeader( cvSize(iFrameWidth  , iFrameHeight  ), IPL_DEPTH_8U, 1 );
    IplImage *iplU420Frame = cvCreateImageHeader( cvSize(iFrameWidth/2, iFrameHeight/2), IPL_DEPTH_8U, 1 );
    IplImage *iplV420Frame = cvCreateImageHeader( cvSize(iFrameWidth/2, iFrameHeight/2), IPL_DEPTH_8U, 1 );

    IplImage *iplY444Frame = cvCreateImage( cvSize(iFrameWidth, iFrameHeight), IPL_DEPTH_8U, 1 );
    IplImage *iplU444Frame = cvCreateImage( cvSize(iFrameWidth, iFrameHeight), IPL_DEPTH_8U, 1 );
    IplImage *iplV444Frame = cvCreateImage( cvSize(iFrameWidth, iFrameHeight), IPL_DEPTH_8U, 1 );

    IplImage *iplYUV444Frame = cvCreateImage( cvSize(iFrameWidth, iFrameHeight), IPL_DEPTH_8U, 3 );

    IplImage *iplRGBFrame0 = cvCreateImage( cvSize(iFrameWidth, iFrameHeight), IPL_DEPTH_8U, 3 );

    while( fread(cFileBuffer0, 1, iFrameWidth*iFrameHeight*3/2, fYUV0) )
    {
        cvSetData( iplY420Frame, cFileBuffer0, iFrameWidth );
        cvSetData( iplU420Frame, cFileBuffer0 + iFrameWidth*iFrameHeight, iFrameWidth/2 );
        cvSetData( iplV420Frame, cFileBuffer0 + iFrameWidth*iFrameHeight*5/4, iFrameWidth/2 );      
        cvResize( iplY420Frame, iplY444Frame );
        cvResize( iplU420Frame, iplU444Frame );
        cvResize( iplV420Frame, iplY444Frame );
        cvMerge( iplY444Frame, iplU444Frame, iplV444Frame, NULL, iplYUV444Frame );
        cvCvtColor( iplYUV444Frame, iplRGBFrame0, CV_YCrCb2BGR );

        cvNamedWindow( "View0" );
        cvShowImage( "View0", iplRGBFrame0 );
        cvWaitKey( 1000/25 );
    }//end-of-while
    cvDestroyWindow( "View0" );
    return 0;
}//end-of-main

PS: Using CV_YCrCb2RGB instead of CV_YCrCb2BGR as above, does not help too. I still get some artificial vertical lines.