示例#1
0
        //解码回调函数
        private void DecCallbackFUN(int nPort, IntPtr pBuf, int nSize, ref PlayCtrl.FRAME_INFO pFrameInfo, int nUser)  //int nReserved1, int nReserved2
        {
            int channel = -1;

            foreach (var item in channelPortDict)
            {
                if (item.Value == nPort)
                {
                    channel = item.Key;
                    break;
                }
            }



            // 将pBuf解码后视频输入写入文件中(解码后YUV数据量极大,尤其是高清码流,不建议在回调函数中处理)
            if (pFrameInfo.nType == 3) //#define T_YV12	3
            {
                if (gloparaDict.ContainsKey(channel))
                {
                    MODSDK.JTMOD_FRAME_INFO frameInfo = new MODSDK.JTMOD_FRAME_INFO();
                    frameInfo.size        = (ushort)Marshal.SizeOf(frameInfo);
                    frameInfo.nWidth      = (ushort)picCapture.Width;
                    frameInfo.nHeight     = (ushort)picCapture.Height;
                    frameInfo.datatype    = 1;
                    frameInfo.lDataLen    = (uint)nSize;
                    frameInfo.iFrameIndex = pFrameInfo.dwFrameNum;
                    frameInfo.timestamp   = (uint)pFrameInfo.nStamp;
                    frameInfo.pData       = pBuf;
                    frameInfo.importGrade = 1;

                    //MODSDK.JtModProcess(glopara, ref frameInfo);

                    int result = MODSDK.JtModProcess(gloparaDict[channel], ref frameInfo);
                }



                //    //    FileStream fs = null;
                //    //    BinaryWriter bw = null;
                //    //    try
                //    //    {
                //    //        fs = new FileStream("DecodedVideo.yuv", FileMode.Append);
                //    //        bw = new BinaryWriter(fs);
                //    //        byte[] byteBuf = new byte[nSize];
                //    //        Marshal.Copy(pBuf, byteBuf, 0, nSize);
                //    //        bw.Write(byteBuf);
                //    //        bw.Flush();
                //    //    }
                //    //    catch (System.Exception ex)
                //    //    {
                //    //        MessageBox.Show(ex.ToString());
                //    //    }
                //    //    finally
                //    //    {
                //    //        bw.Close();
                //    //        fs.Close();
                //    //    }
            }
        }
示例#2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                MODSDK.POINT point = new MODSDK.POINT();
                point.x = 1;
                point.y = 2;

                MODSDK.JTPOLYGON_INFO jtPolygonInfo = new MODSDK.JTPOLYGON_INFO();
                jtPolygonInfo.wType       = 2;
                jtPolygonInfo.wPointCount = 333;

                //IntPtr pPoint = Marshal.AllocCoTaskMem(Marshal.SizeOf(point));
                //Marshal.StructureToPtr(point, pPoint, false);
                //jtPolygonInfo.pPoints = pPoint;

                //jtPolygonInfo.pPoints.x = 1;
                //jtPolygonInfo.pPoints.y = 2;


                MODSDK.JtModTest(ref jtPolygonInfo);


                //MODSDK.POINT newPoint = (MODSDK.POINT)Marshal.PtrToStructure(jtPolygonInfo.pPoints, typeof(MODSDK.POINT));
                //// 释放在非托管代码中分配的Point实例内存
                //Marshal.DestroyStructure(pPoint, typeof(MODSDK.POINT));
            }
            catch (DllNotFoundException dllNotFoundExc)
            {
                Console.WriteLine("DllNotFoundException was detected, "
                                  + "error message: \r\n{0}", dllNotFoundExc.Message);
            }
        }
示例#3
0
        private void btnCallModCreate_Click(object sender, EventArgs e)
        {
            del = new MODSDK.CMP_FRAME_INFO_DELEGATE(onCallback);


            MODSDK.POINT point1 = new MODSDK.POINT();
            point1.x = line[0, 0];
            point1.y = line[0, 1];

            MODSDK.POINT point2 = new MODSDK.POINT();
            point2.x = line[1, 0];
            point2.y = line[1, 1];

            MODSDK.POINT[] points = new MODSDK.POINT[] { point1, point2 };

            MODSDK.JTPOLYGON_INFO jtPolygonInfo = new MODSDK.JTPOLYGON_INFO();
            jtPolygonInfo.wType       = 3;
            jtPolygonInfo.wPointCount = 2;

            IntPtr pPoint  = Marshal.AllocCoTaskMem(Marshal.SizeOf(point1) * points.Length);
            long   LongPtr = pPoint.ToInt64(); // Must work both on x86 and x64

            foreach (MODSDK.POINT p in points)
            {
                IntPtr ptr = new IntPtr(LongPtr);
                Marshal.StructureToPtr(p, ptr, false);
                LongPtr += Marshal.SizeOf(typeof(Point));
            }
            jtPolygonInfo.pPoints = pPoint;
            //jtPolygonInfo.pPoints = new IntPtr(LongPtr);


            MODSDK.JTMOD_OPEN_PARAM jtOpenParam = new MODSDK.JTMOD_OPEN_PARAM();
            jtOpenParam.size      = (ushort)Marshal.SizeOf(jtOpenParam);
            jtOpenParam.nWidth    = (ushort)picCapture.Width;
            jtOpenParam.nHeight   = (ushort)picCapture.Height;
            jtOpenParam.wPolygons = 1;

            IntPtr pPolygons = Marshal.AllocCoTaskMem(Marshal.SizeOf(jtPolygonInfo));

            Marshal.StructureToPtr(jtPolygonInfo, pPolygons, false);
            jtOpenParam.pPolygons = pPolygons;

            jtOpenParam.startobjectID = 1;

            jtOpenParam.cameraIP                = textBoxIP.Text.PadRight(15).ToCharArray();
            jtOpenParam.nChannelID              = (ushort)iChannelNum[(int)iSelIndex]; //textBoxIP.Text + ";";
            jtOpenParam.calibrationObjectWidth  = (uint)rect[0];
            jtOpenParam.calibrationObjectHeight = (uint)rect[0];

            //jtOpenParam.pCallback = del;

            jtOpenParam.dwCallback = 1;

            uint[] dwReverse = new uint[] { 1 };
            jtOpenParam.dwReverse = dwReverse;

            glopara = MODSDK.JtModCreate(ref jtOpenParam);
        }
示例#4
0
        private void btnTest2_Click(object sender, EventArgs e)
        {
            MODSDK.CMP_FRAME_INFO_DELEGATE del = new MODSDK.CMP_FRAME_INFO_DELEGATE(onCallback);


            MODSDK.POINT point = new MODSDK.POINT();
            point.x = 1;
            point.y = 2;

            MODSDK.JTPOLYGON_INFO jtPolygonInfo = new MODSDK.JTPOLYGON_INFO();
            jtPolygonInfo.wType       = 2;
            jtPolygonInfo.wPointCount = 333;

            //IntPtr pPoint = Marshal.AllocCoTaskMem(Marshal.SizeOf(point));
            //Marshal.StructureToPtr(point, pPoint, false);
            //jtPolygonInfo.pPoints = pPoint;


            MODSDK.JTMOD_OPEN_PARAM jtOpenParam = new MODSDK.JTMOD_OPEN_PARAM();
            jtOpenParam.size      = 1;
            jtOpenParam.nWidth    = 1;
            jtOpenParam.nHeight   = 1;
            jtOpenParam.wPolygons = 1;

            IntPtr pPolygons = Marshal.AllocCoTaskMem(Marshal.SizeOf(jtPolygonInfo));

            Marshal.StructureToPtr(jtPolygonInfo, pPolygons, false);
            jtOpenParam.pPolygons = pPolygons;

            jtOpenParam.startobjectID = 1;

            jtOpenParam.pCallback = del;

            jtOpenParam.dwCallback = 1;

            uint[] dwReverse = new uint[] { 1 };
            jtOpenParam.dwReverse = dwReverse;

            MODSDK.JtModCreate(ref jtOpenParam);
        }
示例#5
0
        private void btnCallModCreate_Click(object sender, EventArgs e)
        {
            int selectedChannel = -1;

            int[,] line = new int[2, 2];
            foreach (var item in ptrRealHandleDict)
            {
                if (item.Value == selectedRealPlayWnd.Handle)
                {
                    line            = lineDict[item.Key];
                    selectedChannel = item.Key;
                    break;
                }
            }
            int[] rect = new int[2];
            foreach (var item in ptrRealHandleDict)
            {
                if (item.Value == selectedRealPlayWnd.Handle)
                {
                    rect = rectDict[item.Key];
                    break;
                }
            }

            //del = new MODSDK.CMP_FRAME_INFO_DELEGATE(onCallback);
            if (selectedChannel == 1)
            {
                del1 = new MODSDK.CMP_FRAME_INFO_DELEGATE(onCallback);
            }
            else
            {
                del2 = new MODSDK.CMP_FRAME_INFO_DELEGATE(onCallback);
            }

            MODSDK.POINT point1 = new MODSDK.POINT();
            point1.x = line[0, 0];
            point1.y = line[0, 1];

            MODSDK.POINT point2 = new MODSDK.POINT();
            point2.x = line[1, 0];
            point2.y = line[1, 1];

            MODSDK.POINT[] points = new MODSDK.POINT[] { point1, point2 };

            MODSDK.JTPOLYGON_INFO jtPolygonInfo = new MODSDK.JTPOLYGON_INFO();
            jtPolygonInfo.wType       = 3;
            jtPolygonInfo.wPointCount = 2;

            IntPtr pPoint  = Marshal.AllocCoTaskMem(Marshal.SizeOf(point1) * points.Length);
            long   LongPtr = pPoint.ToInt64(); // Must work both on x86 and x64

            foreach (MODSDK.POINT p in points)
            {
                IntPtr ptr = new IntPtr(LongPtr);
                Marshal.StructureToPtr(p, ptr, false);
                LongPtr += Marshal.SizeOf(typeof(Point));
            }
            jtPolygonInfo.pPoints = pPoint;
            //jtPolygonInfo.pPoints = new IntPtr(LongPtr);


            MODSDK.JTMOD_OPEN_PARAM jtOpenParam = new MODSDK.JTMOD_OPEN_PARAM();
            jtOpenParam.size      = (ushort)Marshal.SizeOf(jtOpenParam);
            jtOpenParam.nWidth    = (ushort)picCapture.Width;
            jtOpenParam.nHeight   = (ushort)picCapture.Height;
            jtOpenParam.wPolygons = 1;

            IntPtr pPolygons = Marshal.AllocCoTaskMem(Marshal.SizeOf(jtPolygonInfo));

            Marshal.StructureToPtr(jtPolygonInfo, pPolygons, false);
            jtOpenParam.pPolygons = pPolygons;

            jtOpenParam.startobjectID = 1;

            jtOpenParam.cameraIP                = textBoxIP.Text.PadRight(15).ToCharArray();
            jtOpenParam.nChannelID              = (ushort)iChannelNum[(int)iSelIndex]; //textBoxIP.Text + ";";
            jtOpenParam.calibrationObjectWidth  = (uint)rect[0];
            jtOpenParam.calibrationObjectHeight = (uint)rect[0];

            //jtOpenParam.pCallback = del;
            if (selectedChannel == 1)
            {
                jtOpenParam.pCallback = del1;
            }
            else
            {
                jtOpenParam.pCallback = del2;
            }

            jtOpenParam.dwCallback = 1;

            uint[] dwReverse = new uint[] { 1 };
            jtOpenParam.dwReverse = dwReverse;

            int glopara = MODSDK.JtModCreate(ref jtOpenParam);

            gloparaDict.Add(selectedChannel, glopara);
        }