Lock Region (to retrieve camera data)

Hi

I’m trying to use the ‘Lock’ region but I’m getting this errror (Gamma 4.12):

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at VL.Lib.Collections.Spread`1.get_Item(Int32 index)
   at _HIKRobotMVSs_.Main.MVSOpen_CProgram_.GetFrames(MVSOpen_C __self, Int32& Result_Out) in C:\Users\Frink\Documents\vvvv\gamma\Sketches\HIKRobotMVSs.vl.cs:line 427
   at _HIKRobotMVSs_.Main.HIKRobotMVSsApplication_KHG2ZwjsqCNOeyhjB2oC7qProgram_.<>c__DisplayClass4_4.<Update__TRACE__>b__4(Object stateInput_188, IReadOnlyList`1 inputs_189, IReadOnlyList`1 incomingLinks_190, Object& stateOutput_192, Spread`1& outputs_193) in C:\Users\Frink\Documents\vvvv\gamma\Sketches\HIKRobotMVSs.vl.cs:line 1267
   at VL.Lib.Primitive.CustomRegionPatch.Update(IReadOnlyList`1 inputs, Spread`1& outputs, IReadOnlyList`1 incomingLinks)
   at _CoreLibBasics_.Control.Try_NXr6u6gowSzLvQTfp53h2q.<>c__DisplayClass2_0.<Update>b__0()
   at VL.Lib.Control.TryCatchUtils.TryCatch[TOutput](Func`1 try, Func`2 catch)

I have a couple of questions.

  1. The error says that I have an out of range error, from a spread. I’m not using one but to check where it could be coming from I I wrapped all of the output in a disabled if, but I got the same error. Pairing down operation to only the lock, I fire the cache around the operation twice and get the same error. How should lock be used.
    image
  2. I’m using the lock because of the code below:
public void ReceiveThreadProcess()
        {
            CFrameout pcFrameInfo = new CFrameout();
            CDisplayFrameInfo pcDisplayInfo = new CDisplayFrameInfo();
            CPixelConvertParam pcConvertParam = new CPixelConvertParam();
            int nRet = CErrorDefine.MV_OK;

            while (m_bGrabbing)
            {
                nRet = m_MyCamera.GetImageBuffer(ref pcFrameInfo, 1000);
                if (nRet == CErrorDefine.MV_OK)
                {
                    lock (BufForDriverLock)
                    {
                        m_pcImgForDriver = pcFrameInfo.Image.Clone() as CImage;
                        m_pcImgSpecInfo = pcFrameInfo.FrameSpec;

                        pcConvertParam.InImage = pcFrameInfo.Image;
                        if (PixelFormat.Format8bppIndexed == m_pcBitmap.PixelFormat)
                        {
                            pcConvertParam.OutImage.PixelType = MvGvspPixelType.PixelType_Gvsp_Mono8;
                            m_MyCamera.ConvertPixelType(ref pcConvertParam);
                        }
                        else
                        {
                            pcConvertParam.OutImage.PixelType = MvGvspPixelType.PixelType_Gvsp_BGR8_Packed;
                            m_MyCamera.ConvertPixelType(ref pcConvertParam);
                        }

                        // ch:保存Bitmap数据 | en:Save Bitmap Data
                        BitmapData m_pcBitmapData = m_pcBitmap.LockBits(new Rectangle(0, 0, pcConvertParam.InImage.Width, pcConvertParam.InImage.Height), ImageLockMode.ReadWrite, m_pcBitmap.PixelFormat);
                        Marshal.Copy(pcConvertParam.OutImage.ImageData, 0, m_pcBitmapData.Scan0, (Int32)pcConvertParam.OutImage.ImageData.Length);
                        m_pcBitmap.UnlockBits(m_pcBitmapData);
                    }

                    pcDisplayInfo.WindowHandle = pictureBox1.Handle;
                    pcDisplayInfo.Image = pcFrameInfo.Image;
                    m_MyCamera.DisplayOneFrame(ref pcDisplayInfo);

                    m_MyCamera.FreeImageBuffer(ref pcFrameInfo);
                }
                else
                {
                    if (bnTriggerMode.Checked)
                    {
                        Thread.Sleep(5);
                    }
                }
            }
        }

An so far I have this:

image

The rest of the camera setup seems to be going according to the documentation, and this is the file step that gives me an error, but does the patch look okay?

There has been a bug in the Lock region. Thanks for the report. Fixed in upcoming.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.