Difference between revisions of "2253"
(→Troubleshooting LEDs) |
|||
(23 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | == Solving devices with serial number 0 == | ||
+ | |||
+ | See [[Windows10Privacy|Turn on Windows 10 app access for camera and microphone]]. | ||
+ | |||
+ | == Installation Prerequisites for CentOS/Fedora == | ||
+ | |||
+ | sudo yum install kernel-devel ImageMagick-devel | ||
+ | |||
== Cross-compiling Linux driver for ARM == | == Cross-compiling Linux driver for ARM == | ||
Line 10: | Line 18: | ||
For the demo application, modify the Makefile path to the cross compiler, then do "make demo_arm". | For the demo application, modify the Makefile path to the cross compiler, then do "make demo_arm". | ||
+ | |||
+ | See also: [[2253_Raspberry_Pi]], [[2253_Toradex]] | ||
== Connecting to USB 3.0 ports on Linux == | == Connecting to USB 3.0 ports on Linux == | ||
Line 19: | Line 29: | ||
[ 378.488958] usb 9-1: device descriptor read/8, error -75 | [ 378.488958] usb 9-1: device descriptor read/8, error -75 | ||
− | Reconnect the device to a USB 2.0 port, or contact support@sensoray.com for RMA. | + | Reconnect the device to a USB 2.0 port, or contact support@sensoray.com for RMA. Boards manufactured after April 2013 have corrected this issue. (Windows is not affected.) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== Overlays == | == Overlays == | ||
Line 35: | Line 38: | ||
S2253_SetOverlay, S2253_StreamOverlay | S2253_SetOverlay, S2253_StreamOverlay | ||
− | In the manual, S2253_StreamOverlay talks of the input stream. This is an input stream to the 2253 for decoding | + | In the manual, S2253_StreamOverlay talks of the input stream. This is an input stream to the 2253 for decoding. The actual overlay is output onto the physical output video channel. |
− | 2) Overlay (Bitmap) on the preview window on the host preview (not saved in recordings). | + | 2) Overlay (Bitmap) on the preview window on the host preview (not saved in recordings, not output on composite out). |
S2253_DrawBitmap,S2253_DrawBitmapColorRef | S2253_DrawBitmap,S2253_DrawBitmapColorRef | ||
− | 3) Overlay (Text, Monochrome Bitmap) in the stream itself. | + | 3) Overlay (Text, Monochrome Bitmap) in the stream itself. This overlay will be present on snapshots and recorded files. |
S2253_SetOsd | S2253_SetOsd | ||
+ | |||
+ | == Overlay Specifications == | ||
+ | |||
+ | One line of text for each video stream (A, B, Output) up to 160 characters, and may include newline (^n) or date (^d) or time (^t) codes inserted. | ||
+ | |||
+ | For styled text, there are 16 overlay regions for Stream A and B, and 255 regions for Output Stream. Bitmaps or PNG images can only be used on the Output Stream. The overlay resolution is not directly limited, but the decoding of the PNG image takes time, and transferring large BMP images over USB and then decoding takes time. For the Output Stream, the overlay image is applied to a masking buffer once and the output video is rendered in hardware. For the Encoded Streams, the overlay image must be rendered in software for every frame, and too many or too large overlays can cause video frames to be dropped. | ||
== Example for Preview Bitmap Drawing in C# == | == Example for Preview Bitmap Drawing in C# == | ||
+ | |||
+ | This example shows how to do overlay type #2 listed above. The overlay will ONLY appear in the preview Window. It will not be saved to recorded files or snapshots. It will not appear on the composite output. | ||
If using 64 bit applications, make sure to set the VMR to VMR9 using S2253_SetPreviewType. | If using 64 bit applications, make sure to set the VMR to VMR9 using S2253_SetPreviewType. | ||
Line 49: | Line 60: | ||
Below is sample code to draw a Bitmap to the video preview in C#: | Below is sample code to draw a Bitmap to the video preview in C#: | ||
− | + | Bitmap mybmp = new Bitmap(100, 100); | |
− | + | S2253.NORMALIZEDRECT nRect; | |
− | + | int retVal; | |
− | + | S2253.RECTANGLE sRect; | |
− | + | sRect.left = 0; | |
− | + | sRect.top = 0; | |
− | + | sRect.right = mybmp.Width; | |
− | + | sRect.bottom = mybmp.Height; | |
− | + | Graphics myGraphics = Graphics.FromImage(mybmp); | |
− | + | myGraphics.DrawLine(new Pen(Color.Green, 5.0f), new Point(0, 0), new Point(50, 50)); | |
− | + | nRect.bottom = 0.9f; | |
− | + | nRect.top = 0.1f; | |
− | + | nRect.left = 0.1f; | |
− | + | nRect.right = 0.9f; | |
− | + | IntPtr hdcBMP = myGraphics.GetHdc(); | |
− | + | S2253.SelectObject(hdcBMP, mybmp.GetHbitmap()); | |
− | + | retVal = S2253.DrawBitmap(hdcBMP, ref sRect, ref nRect, 0.5f, 0, 0); | |
− | + | myGraphics.ReleaseHdc(); | |
In mid2253.cs, define the following if it does not already exist: | In mid2253.cs, define the following if it does not already exist: | ||
− | + | public struct RECTANGLE { | |
− | + | public Int32 left; | |
− | + | public Int32 top; | |
− | + | public Int32 right; | |
− | + | public Int32 bottom; | |
− | + | }; | |
− | + | public struct NORMALIZEDRECT { | |
− | + | public float left; | |
− | + | public float top; | |
− | + | public float right; | |
− | + | public float bottom; | |
− | + | }; | |
− | + | ||
− | + | public static Int32 DrawBitmap(IntPtr hdcBMP, ref RECTANGLE src, | |
− | + | ref NORMALIZEDRECT dst, float alpha, int devid, int strmid) | |
− | + | { | |
− | + | int retVal; | |
− | + | retVal = S2253_DrawBitmap(hdcBMP, ref src, ref dst, alpha, devid, strmid); | |
− | + | return retVal; | |
+ | } | ||
− | + | public static Int32 DrawBitmapColorRef(IntPtr hdcBMP, ref RECTANGLE src, | |
− | + | ref NORMALIZEDRECT dst, float alpha, UInt32 clrSrcKey, int devid, int strmid) | |
− | + | { | |
− | + | int retVal; | |
− | + | retVal = S2253_DrawBitmapColorRef(hdcBMP, ref src, ref dst, alpha, clrSrcKey, devid, strmid); | |
− | + | return retVal; | |
+ | } | ||
− | + | [DllImport("mid2253.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)] | |
− | + | static extern Int32 S2253_DrawBitmap(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, _ | |
float alpha, int devid, int strmidx); | float alpha, int devid, int strmidx); | ||
− | + | [DllImport("mid2253.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)] | |
− | + | static extern Int32 S2253_DrawBitmapColorRef(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, _ | |
float alpha, UInt32 clrSrcKey, int devid, int strmidx); | float alpha, UInt32 clrSrcKey, int devid, int strmidx); | ||
− | + | [DllImport("gdi32.dll", EntryPoint = "SelectObject", CallingConvention = CallingConvention.Cdecl)] | |
+ | public static extern IntPtr SelectObject(IntPtr hdc, IntPtr h); | ||
== Monochrome Overlay on Device with C# == | == Monochrome Overlay on Device with C# == | ||
+ | |||
+ | This example shows how to do overlay type #3 listed above. The overlay will appear in recorded files, snapshots, and the composite video output. | ||
Add the following to mid2253.cs: | Add the following to mid2253.cs: | ||
Line 115: | Line 130: | ||
public struct MID2253_OSD_BMP | public struct MID2253_OSD_BMP | ||
{ | { | ||
− | public int osdOn; | + | public int osdOn; // OSD on if != 0 |
− | public int osdChan; | + | public int osdChan; // osd channel to update: 0 = stream A; 1 = stream B, 2 = output, 3 = both streams |
− | public int id; | + | public int id; // region id: 0..15 |
− | public int xoffset; | + | public int xoffset; // x offset: relative to left |
− | public int yoffset; | + | public int yoffset; // y offset: relative to top |
− | public IntPtr bmp; | + | public IntPtr bmp; // pointer to bitmap image data (as loaded from file) |
}; | }; | ||
+ | Add the following to mid2253.cs: | ||
− | + | public static Int32 SetOsd(ref MID2253_OSD_BMP osd, Int32 devid, Int32 strmidx) | |
− | + | ||
− | public static Int32 SetOsd( ref MID2253_OSD_BMP osd, Int32 devid, Int32 strmidx ) | + | |
{ | { | ||
int hr; | int hr; | ||
Line 137: | Line 151: | ||
r.bmp = osd.bmp; | r.bmp = osd.bmp; | ||
− | hr = S2253_SetOsd( MID2253_OSDTYPE.MID2253_OSDTYPE_BMP, ref r, devid, strmidx ); | + | hr = S2253_SetOsd(MID2253_OSDTYPE.MID2253_OSDTYPE_BMP, ref r, devid, strmidx); |
return hr; | return hr; | ||
} | } | ||
Line 143: | Line 157: | ||
Example code for C# Form loading bitmap from file: | Example code for C# Form loading bitmap from file: | ||
{ | { | ||
− | + | int brd_idx = 0; | |
− | + | int streamIdx = 0; | |
− | + | MemoryStream strm = new MemoryStream(); | |
− | + | S2253.MID2253_OSD_BMP osdBmp = new S2253.MID2253_OSD_BMP(); | |
− | + | ImageConverter converter = new ImageConverter(); | |
− | + | Bitmap mybmp = (Bitmap) Bitmap.FromFile("Logo.bmp"); | |
− | + | byte[] bmpByteArray = new byte[0]; | |
− | + | using (strm) { | |
− | + | mybmp.Save(strm, System.Drawing.Imaging.ImageFormat.Bmp); | |
− | + | strm.Close(); | |
− | + | bmpByteArray = strm.ToArray(); | |
− | + | } | |
− | + | GCHandle pinnedArray = GCHandle.Alloc(bmpByteArray, GCHandleType.Pinned); | |
− | + | IntPtr ptr = pinnedArray.AddrOfPinnedObject(); | |
− | + | osdBmp.bmp = ptr; | |
− | + | osdBmp.id = 1; | |
− | + | osdBmp.osdChan = 3; | |
− | + | osdBmp.osdOn = 1; | |
− | + | osdBmp.xoffset = 50; | |
− | + | osdBmp.yoffset = 50; | |
− | + | int retVal = S2253.SetOsd(ref osdBmp, brd_idx, streamIdx); | |
− | + | pinnedArray.Free(); | |
} | } | ||
+ | |||
+ | == Monochrome Overlay on Device with C++ == | ||
+ | |||
+ | This example shows how to do overlay type #3 listed above. The overlay will appear in recorded files, snapshots, and the composite video output. | ||
+ | |||
+ | { | ||
+ | MID2253_OSD_DATA osd; | ||
+ | FILE *fin; | ||
+ | unsigned char *pdata; | ||
+ | size_t rsize; | ||
+ | osd.osdbmp.id = 0; | ||
+ | osd.osdbmp.osdOn = 1; | ||
+ | osd.osdbmp.osdChan = 3; | ||
+ | osd.osdbmp.xoffset = 200; | ||
+ | osd.osdbmp.yoffset = 300; | ||
+ | fin = fopen("logo.bmp", "rb"); | ||
+ | pdata = (unsigned char *) malloc(50 * 1024); | ||
+ | rsize = fread(pdata, 1, 50*1024, fin); | ||
+ | osd.osdbmp.bmp = pdata; | ||
+ | S2253_SetOsd(MID2253_OSDTYPE_BMP, &osd, 0, 0); | ||
+ | free(pdata); | ||
+ | fclose(fin); | ||
+ | } | ||
+ | |||
+ | '''Note:''' Above code is for demonstration purposes only. Please add error checking to production code. | ||
+ | |||
+ | == Troubleshooting LEDs == | ||
+ | |||
+ | {| class="wikitable" | ||
+ | ! D1<br>green || D2<br>red || D3<br>amber || Status | ||
+ | |- | ||
+ | | on || || || board has power | ||
+ | |- | ||
+ | | || off || blink || waiting for firmware | ||
+ | |- | ||
+ | | || off || on || firmware is loading | ||
+ | |- | ||
+ | | || on || on || firmware kernel is started | ||
+ | |- | ||
+ | | || off || off || firmware kernel booted successfully | ||
+ | |} | ||
− | [[Category: | + | [[Category:2253| ]] |
Latest revision as of 09:48, 10 March 2022
[edit] Solving devices with serial number 0
See Turn on Windows 10 app access for camera and microphone.
[edit] Installation Prerequisites for CentOS/Fedora
sudo yum install kernel-devel ImageMagick-devel
[edit] Cross-compiling Linux driver for ARM
From sdk_2253_x.y.z_linux/driver:
PATH=<path-to-cross-compiler/bin>:$PATH \ make -C <path-to-target-kernel-directory> SUBDIRS=`pwd` \ CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm modules
Copy the s2253.ko file to the target's /lib/modules/`uname -r`/extra directory, and run "depmod -a".
For the demo application, modify the Makefile path to the cross compiler, then do "make demo_arm".
See also: 2253_Raspberry_Pi, 2253_Toradex
[edit] Connecting to USB 3.0 ports on Linux
When connecting the board to a port on a USB 3.0 (SuperSpeed) hub, if the device does not work, check the dmesg log for these messages:
[ 378.352045] usb 9-1: new high-speed USB device number 19 using xhci_hcd [ 378.369004] usb 9-1: device descriptor read/8, error -75 [ 378.488958] usb 9-1: device descriptor read/8, error -75
Reconnect the device to a USB 2.0 port, or contact support@sensoray.com for RMA. Boards manufactured after April 2013 have corrected this issue. (Windows is not affected.)
[edit] Overlays
The 2253 has three types of overlays.
1) Overlay (Bitmap) on the physical composite output video channel. S2253_SetOverlay, S2253_StreamOverlay
In the manual, S2253_StreamOverlay talks of the input stream. This is an input stream to the 2253 for decoding. The actual overlay is output onto the physical output video channel.
2) Overlay (Bitmap) on the preview window on the host preview (not saved in recordings, not output on composite out). S2253_DrawBitmap,S2253_DrawBitmapColorRef
3) Overlay (Text, Monochrome Bitmap) in the stream itself. This overlay will be present on snapshots and recorded files. S2253_SetOsd
[edit] Overlay Specifications
One line of text for each video stream (A, B, Output) up to 160 characters, and may include newline (^n) or date (^d) or time (^t) codes inserted.
For styled text, there are 16 overlay regions for Stream A and B, and 255 regions for Output Stream. Bitmaps or PNG images can only be used on the Output Stream. The overlay resolution is not directly limited, but the decoding of the PNG image takes time, and transferring large BMP images over USB and then decoding takes time. For the Output Stream, the overlay image is applied to a masking buffer once and the output video is rendered in hardware. For the Encoded Streams, the overlay image must be rendered in software for every frame, and too many or too large overlays can cause video frames to be dropped.
[edit] Example for Preview Bitmap Drawing in C#
This example shows how to do overlay type #2 listed above. The overlay will ONLY appear in the preview Window. It will not be saved to recorded files or snapshots. It will not appear on the composite output.
If using 64 bit applications, make sure to set the VMR to VMR9 using S2253_SetPreviewType.
Below is sample code to draw a Bitmap to the video preview in C#:
Bitmap mybmp = new Bitmap(100, 100); S2253.NORMALIZEDRECT nRect; int retVal; S2253.RECTANGLE sRect; sRect.left = 0; sRect.top = 0; sRect.right = mybmp.Width; sRect.bottom = mybmp.Height; Graphics myGraphics = Graphics.FromImage(mybmp); myGraphics.DrawLine(new Pen(Color.Green, 5.0f), new Point(0, 0), new Point(50, 50)); nRect.bottom = 0.9f; nRect.top = 0.1f; nRect.left = 0.1f; nRect.right = 0.9f; IntPtr hdcBMP = myGraphics.GetHdc(); S2253.SelectObject(hdcBMP, mybmp.GetHbitmap()); retVal = S2253.DrawBitmap(hdcBMP, ref sRect, ref nRect, 0.5f, 0, 0); myGraphics.ReleaseHdc();
In mid2253.cs, define the following if it does not already exist:
public struct RECTANGLE { public Int32 left; public Int32 top; public Int32 right; public Int32 bottom; }; public struct NORMALIZEDRECT { public float left; public float top; public float right; public float bottom; };
public static Int32 DrawBitmap(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, float alpha, int devid, int strmid) { int retVal; retVal = S2253_DrawBitmap(hdcBMP, ref src, ref dst, alpha, devid, strmid); return retVal; }
public static Int32 DrawBitmapColorRef(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, float alpha, UInt32 clrSrcKey, int devid, int strmid) { int retVal; retVal = S2253_DrawBitmapColorRef(hdcBMP, ref src, ref dst, alpha, clrSrcKey, devid, strmid); return retVal; }
[DllImport("mid2253.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)] static extern Int32 S2253_DrawBitmap(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, _ float alpha, int devid, int strmidx);
[DllImport("mid2253.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)] static extern Int32 S2253_DrawBitmapColorRef(IntPtr hdcBMP, ref RECTANGLE src, ref NORMALIZEDRECT dst, _ float alpha, UInt32 clrSrcKey, int devid, int strmidx);
[DllImport("gdi32.dll", EntryPoint = "SelectObject", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr SelectObject(IntPtr hdc, IntPtr h);
[edit] Monochrome Overlay on Device with C#
This example shows how to do overlay type #3 listed above. The overlay will appear in recorded files, snapshots, and the composite video output.
Add the following to mid2253.cs:
public struct MID2253_OSD_BMP { public int osdOn; // OSD on if != 0 public int osdChan; // osd channel to update: 0 = stream A; 1 = stream B, 2 = output, 3 = both streams public int id; // region id: 0..15 public int xoffset; // x offset: relative to left public int yoffset; // y offset: relative to top public IntPtr bmp; // pointer to bitmap image data (as loaded from file) };
Add the following to mid2253.cs:
public static Int32 SetOsd(ref MID2253_OSD_BMP osd, Int32 devid, Int32 strmidx) { int hr; MID2253_OSD_BMP r; r.osdChan = osd.osdChan; r.osdOn = osd.osdOn; r.id = osd.id; r.xoffset = osd.xoffset; r.yoffset = osd.yoffset; r.bmp = osd.bmp; hr = S2253_SetOsd(MID2253_OSDTYPE.MID2253_OSDTYPE_BMP, ref r, devid, strmidx); return hr; }
Example code for C# Form loading bitmap from file:
{ int brd_idx = 0; int streamIdx = 0; MemoryStream strm = new MemoryStream(); S2253.MID2253_OSD_BMP osdBmp = new S2253.MID2253_OSD_BMP(); ImageConverter converter = new ImageConverter(); Bitmap mybmp = (Bitmap) Bitmap.FromFile("Logo.bmp"); byte[] bmpByteArray = new byte[0]; using (strm) { mybmp.Save(strm, System.Drawing.Imaging.ImageFormat.Bmp); strm.Close(); bmpByteArray = strm.ToArray(); } GCHandle pinnedArray = GCHandle.Alloc(bmpByteArray, GCHandleType.Pinned); IntPtr ptr = pinnedArray.AddrOfPinnedObject(); osdBmp.bmp = ptr; osdBmp.id = 1; osdBmp.osdChan = 3; osdBmp.osdOn = 1; osdBmp.xoffset = 50; osdBmp.yoffset = 50; int retVal = S2253.SetOsd(ref osdBmp, brd_idx, streamIdx); pinnedArray.Free(); }
[edit] Monochrome Overlay on Device with C++
This example shows how to do overlay type #3 listed above. The overlay will appear in recorded files, snapshots, and the composite video output.
{ MID2253_OSD_DATA osd; FILE *fin; unsigned char *pdata; size_t rsize; osd.osdbmp.id = 0; osd.osdbmp.osdOn = 1; osd.osdbmp.osdChan = 3; osd.osdbmp.xoffset = 200; osd.osdbmp.yoffset = 300; fin = fopen("logo.bmp", "rb"); pdata = (unsigned char *) malloc(50 * 1024); rsize = fread(pdata, 1, 50*1024, fin); osd.osdbmp.bmp = pdata; S2253_SetOsd(MID2253_OSDTYPE_BMP, &osd, 0, 0); free(pdata); fclose(fin); }
Note: Above code is for demonstration purposes only. Please add error checking to production code.
[edit] Troubleshooting LEDs
D1 green |
D2 red |
D3 amber |
Status |
---|---|---|---|
on | board has power | ||
off | blink | waiting for firmware | |
off | on | firmware is loading | |
on | on | firmware kernel is started | |
off | off | firmware kernel booted successfully |