Reading the Input in C#

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Denis Nikolaev

  • Posts: 4
  • Joined: Wed May 06, 2015 7:55 pm

Reading the Input in C#

PostWed May 06, 2015 8:13 pm

Hi all.
I have a task of displaying the camera's capture in WinForms application.

First of all i tried to save raw data to a file
Code: Select all
public void VideoInputFrameArrived(IDeckLinkVideoInputFrame video, IDeckLinkAudioInputPacket audio)
{
IntPtr pData;
video.GetBytes(out pData );

byte[] buffer = new byte[1920 * 1080 * 4];

System.Runtime.InteropServices.Marshal.Copy( pData, buffer, 0, buffer.Length );
System.IO.FileStream file = new System.IO.FileStream("frame" + frameCount + ".raw", System.IO.FileMode.Create);
file.Write(buffer, 0, buffer.Length);
file.Close();


but I always get all the pixels are black. Actually as far as pixelformat I have setted is 32bppABGR,
I get FF 00 00 00 for each pixel.

Could somebody tell me where is my mistake?
And one more thing: could somebody provide me a shortest way to display raw data in WinForm Window (I am new in WinForms)

Thanks a lot
Offline
User avatar

Roman Ryltsov

  • Posts: 21
  • Joined: Sun May 12, 2013 6:52 pm
  • Location: Kharkov, Ukraine

Re: Reading the Input in C#

PostThu May 07, 2015 5:40 am

Capture in incorrect format, which does not match incoming signal?
Offline

Denis Nikolaev

  • Posts: 4
  • Joined: Wed May 06, 2015 7:55 pm

Re: Reading the Input in C#

PostThu May 07, 2015 6:31 am

Thanks for attention.
The mode I set in this way:
Code: Select all
                _BMDDisplayMode setDisplayMode = _BMDDisplayMode.bmdModeHD1080p50;
                _BMDPixelFormat setPixelFormat = _BMDPixelFormat.bmdFormat8BitARGB;
                _BMDVideoInputFlags setInputFlag = _BMDVideoInputFlags.bmdVideoInputFlagDefault;

                _deckLinkInput.DoesSupportVideoMode(setDisplayMode, setPixelFormat, setInputFlag, out displayModeSupport, out displayMode);

                if (displayMode.GetDisplayMode() == _BMDDisplayMode.bmdModeHD1080p50)
                {
                    Console.WriteLine("Video mode at HD1080p50 OK");
                }
                else
                {
                    Console.WriteLine("Video mode at HD1080p50 error");
                }

                if (displayModeSupport == _BMDDisplayModeSupport.bmdDisplayModeSupported)
                {
                    Console.WriteLine("display mode at HD1080p50 OK");
                }
                else
                {
                    Console.WriteLine("display mode at HD1080p50 error");
                }
                try
                {
                    _deckLinkInput.EnableVideoInput(setDisplayMode, setPixelFormat, setInputFlag);

                }
                catch (Exception em)
                {
                    Console.WriteLine("deck link init failed: " + em.Message);
                }

                _deckLinkInput.SetCallback(this);
Offline
User avatar

Roman Ryltsov

  • Posts: 21
  • Joined: Sun May 12, 2013 6:52 pm
  • Location: Kharkov, Ukraine

Re: Reading the Input in C#

PostFri May 08, 2015 6:33 am

If your signal is not 1080p50, or default input connection is not the one you have your cable connected with - you get black screen. Make sure Control Panel settings are good for your capture card, and Media express captures video well.
Offline

Denis Nikolaev

  • Posts: 4
  • Joined: Wed May 06, 2015 7:55 pm

Re: Reading the Input in C#

PostFri May 08, 2015 7:32 am

I got the normal frame buffer only in YUV8bit pixel format not the bmdFormat8BitARGB which i wanted. Is it possible to change pixel format somehow programmatically? Or it can be changed only manually in camera own display menu? The problem is that I try solve the problem remotely without having the camera
Offline

Denis Nikolaev

  • Posts: 4
  • Joined: Wed May 06, 2015 7:55 pm

Re: Reading the Input in C#

PostFri May 08, 2015 9:42 am

Sorry. Just read your posts in this topic (loosing RGB formats on new drivers). I got the same problem. This topic is solved. For all: be sure about the mode and pixel format you selected.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 2 guests