1

我制作了一个仪表,显示相机中的最大强度。为了制作仪表,我首先将拨号器放在面板的背景中,然后在该面板上的图片框和具有透明背景的图片框上画针。

我的代码如下...

private: System::Void FocusExposure_Load(System::Object^  sender, System::EventArgs^  e) {
                 th = gcnew Thread(gcnew ThreadStart(this,&FocusExposure::UpdateIntensity)); 
                th->Start();            
             }

void UpdateIntensity()
     {
         int intensity=0;
        Intensity_Values data;
         while(1)
         {
         data = ReadImage(cameraBuffer);
                 if(count == 1)
                 {
                     count++;
                    label14->Text =  Convert::ToString(data.Max);
                 }
             label7->Text =  Convert::ToString(data.Max);
             label8->Text =  Convert::ToString(data.Min);
             label9->Text =  Convert::ToString(data.Avg);
             label10->Text =  Convert::ToString(data.Max_Min);
            draw_Intens( data.Max);
         }
     }
private: void draw_Intens(int intensity)
             {

                 this->pictureBox1->Refresh();
                 double const PI = 3.14159265358979323;
                 float degree=angle_array[intensity]*PI/180;
                 circumPoint xy= cordinate_point(degree);

                 Graphics ^ graphics = pictureBox1->CreateGraphics(); 
                 SolidBrush^ shadowBrush = gcnew SolidBrush( Color::Blue );
                     Pen^ penCurrent = gcnew Pen(Color::Blue,3);
                                    graphics->FillEllipse(shadowBrush, 93, 93,14, 14);
                                    graphics->DrawLine(penCurrent, Point(100, 100), Point(xy.x, xy.y));
                                    delete penCurrent;
                                    delete shadowBrush;
                                    delete graphics;
            }
circumPoint cordinate_point(float degree)
         { 
             circumPoint pointxy;
             pointxy.x =  100+redius * cos(degree);
             pointxy.y =  100+redius * sin(degree);
             return pointxy;
         }

angle_array是一个double angle_array[]={126.000000,126.070313,126.140625,...,414.000000}具有 4097 个角度值的数组,使用这些值针会旋转。

ReadImage(cameraBuffer)是一个返回 Max、Min、Avg、Max_Min 强度值的函数。

Intensity_Values是 Max Min Avg Max_Min 值的结构。

typedef struct {
   int  Max;
   int  Min;
   int  Avg;
   int Max_Min;
} Intensity_Values;

我的表是这样的...

在此处输入图像描述

左侧的最小强度为 0,右侧的最大强度值为 4096。

现在我的问题是,当我运行我的应用程序时,它会启动并在 2 3 秒后挂起或可以说停止工作。我认为问题可能是内存泄漏,但我不知道问题出在哪里。

请帮助我摆脱这个问题。

任何帮助将不胜感激。

谢谢。

4

0 回答 0