Note that there are some explanatory texts on larger screens.

plurals
  1. POCreated a UYVY image over directshow and its corrupted and im not sure why
    primarykey
    data
    text
    <p>I have a buffer of UYVY data from a camera and i am using the GSSF Directshow.net filter to push the buffer through a graph. </p> <p>The Graph at the moment is</p> <pre><code>GSSF -&gt; YUV Transform -&gt; AVI Splitter -&gt; Video Renderer </code></pre> <p>The graph correctly calculates the color and is displaying it correctly but theres bars in the image that shouldn't be there and i am not sure where they are coming from. It hurts my eyes to stare at the image.</p> <p><img src="https://i.stack.imgur.com/UdHkt.png" alt="enter image description here"></p> <p>This function takes the UYVY buffer (mainbyte) and copies it to an array of integers</p> <pre><code> unsafe public void ImageFromPixels__() { byte[] x = mainbyte; long fff = 720 * 1280; mainptr = new IntPtr(fff); for (int p = 0; p &lt; 720 * 1280; p++) { U = (x[p * 4 + 0]); Y = (x[p * 4 + 1]); V = (x[p * 4 + 2]); Y2 = (x[p * 4 + 3]); // int one = V &lt;&lt; 16 | Y &lt;&lt; 8 | U; // int two = V &lt;&lt; 16 | Y2 &lt;&lt; 8 | U; int one = Y2 &lt;&lt; 24 | V &lt;&lt; 16 | Y &lt;&lt; 8 | U; // mainint[p * 2 + 0] = one; // mainint[p * 2 + 1] = two; mainint[p] = one; } m_FPS = UNIT / 20; m_b = 211; m_g = 197; } </code></pre> <p>This function takes that same array of integers and packs it into the GSSF stream pointer</p> <pre><code> override unsafe public int GetImage(int iFrameNumber, IntPtr ip, int iSize, out int iRead) { int hr = 0; if (iFrameNumber&gt;-1) { if (iFrameNumber &lt; MAXFRAMES) { ImageFromPixels_(20, mainbyte); m_g += 3; m_b += 7; int* bp = (int*)ip.ToPointer(); Random k = new Random(); StreamReader s = new StreamReader("jpegFile.txt"); for (int f = 0; f &lt; HEIGHT; f++) { for (int x = 0; x &lt; (WIDTH); x += 1) { *(bp + (f * WIDTH) + x) = mainint[f * 1280 + x]; } } } else { hr = 1; // End of stream } } iRead = iSize; return hr; } </code></pre> <p>This sets up the bitmap compression for the output pin of the GSSF I think i may be doing something wrong here but it looks correct.</p> <pre><code> override public void SetMediaType(IGenericSampleConfig psc) { BitmapInfoHeader bmi = new BitmapInfoHeader(); // Build a BitmapInfo struct using the parms from the file bmi.Size = Marshal.SizeOf(typeof(BitmapInfoHeader)); bmi.Width = WIDTH; bmi.Height = HEIGHT * -1; bmi.Planes = 1; bmi.BitCount = BPP; bmi.Compression = 0x59565955; //UYVY bmi.ImageSize = (bmi.BitCount / 8) * bmi.Width * bmi.Height; bmi.XPelsPerMeter = 0; bmi.YPelsPerMeter = 0; bmi.ClrUsed = 0; bmi.ClrImportant = 0; int hr = psc.SetMediaTypeFromBitmap(bmi, m_FPS); DsError.ThrowExceptionForHR(hr); } </code></pre> <p><strong>UPDATE</strong> changed it abit</p> <pre><code> override unsafe public int GetImage(int iFrameNumber, IntPtr ip, int iSize, out int iRead) { int hr = 0; if (iFrameNumber&gt;-1) { if (iFrameNumber &lt; MAXFRAMES) { ImageFromPixels_(20, mainbyte); m_g += 3; m_b += 7; int* bp = (int*)ip.ToPointer(); Random k = new Random(); StreamReader s = new StreamReader("jpegFile.txt"); for (int f = 0; f &lt; 720; f++) { for (int x = 0; x &lt; (1280); x += 1) { *(bp + (f * 1280) + x) = mainint[f * 1280 + x]; } } } else { hr = 1; // End of stream } } </code></pre> <p>// override public void SetMediaType(IGenericSampleConfig psc) { BitmapInfoHeader bmi = new BitmapInfoHeader();</p> <pre><code> // Build a BitmapInfo struct using the parms from the file bmi.Size = Marshal.SizeOf(typeof(BitmapInfoHeader)); bmi.Width = WIDTH; bmi.Height = HEIGHT * -1; bmi.Planes = 1; bmi.BitCount = BPP; bmi.Compression = 0x59565955; bmi.ImageSize = (bmi.BitCount / 8) * bmi.Width * bmi.Height; bmi.XPelsPerMeter = 0; bmi.YPelsPerMeter = 0; bmi.ClrUsed = 0; bmi.ClrImportant = 0; int hr = psc.SetMediaTypeFromBitmap(bmi, m_FPS); DsError.ThrowExceptionForHR(hr); } </code></pre> <p>//</p> <pre><code> unsafe public void ImageFromPixels_(long FPS, byte[] x) { long fff = 720 * 1280 * 3; mainptr = new IntPtr(fff); for (int p = 0; p &lt; 720 * 640; p++) { U = (x[ p * 4 + 0]); Y = (x[p * 4 + 1]); V = (x[p * 4 + 2]); Y2 = (x[p * 4 + 3]); int one = Y2 &lt;&lt; 24 | V &lt;&lt; 16 | Y &lt;&lt; 8 | U; //int one = V &lt;&lt; 16 | Y &lt;&lt; 8 | U; //int two = V &lt;&lt; 16 | Y2 &lt;&lt; 8 | U; //mainint[p * 2 + 0] = one; //mainint[p * 2 + 1] = two; mainint[p] = one; } m_FPS = UNIT / FPS; m_b = 211; m_g = 197; } </code></pre> <p><img src="https://i.stack.imgur.com/1LUda.png" alt="enter image description here"></p> <p>if i change the other numbers within GetImage to alter the height of the video, or if i chnge it inside of ImagePixel then i just get black screens :|</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload