📄 unit1.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "math.h"
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Ant.h"
#include "time.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AntTool AT;
//short *tryextern = new short[10];
short **contour_x_coordinate = new short*[10];//Setting 10 candidates of contour at most in an image.
short **contour_y_coordinate = new short*[10];//Setting 10 candidates of contour at most in an image.
short *scaled_x_coordinate_1;
short *scaled_y_coordinate_1;
short *total_number = new short(0);//count the total points of the contour
short *chain_code_1;
short *break_point_x_coordinate_1;
short *break_point_y_coordinate_1;
short *number_of_break_point_1 = new short(0);
short *supporting_region_1;
double *K_cosine_1;
short *number_of_initial_point_1 = new short(0);
short *initial_solution_x_coordinate_1;
short *initial_solution_y_coordinate_1;
bool *open_chain_code_1 = new bool (false);
TImage *chain_code_IMG_1 = new TImage(0);
TRect chain_code_source_1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ConturTracking1Click(TObject *Sender)
{
Form1->Hide();
Form2->Show();
Form2->ProgressBar1->Min=0;
Form2->ProgressBar1->Max=10;
Image1->Picture->Bitmap->PixelFormat=pf24bit;
// TImage* HelpImage= new TImage(0);
TImage* temp= new TImage(0);
temp->Picture->Bitmap->PixelFormat=pf24bit;
TRect TheRect=Rect(0,0,Image1->Width-1,Image1->Height-1);
// HelpImage->Picture->Bitmap->Height=Image1->Height;
// HelpImage->Picture->Bitmap->Width=Image1->Width;
// HelpImage->Picture->Bitmap->PixelFormat=pf24bit;
temp->Picture->Bitmap->Height=Image1->Height;
temp->Picture->Bitmap->Width=Image1->Width;
// Image3->Picture->Bitmap->Height=Image1->Height;
// Image3->Picture->Bitmap->Width=Image1->Width;
// HelpImage->Canvas->CopyRect(TheRect,Image1->Canvas,TheRect);
// Image2->Height=Image1->Height;
// Image2->Width=Image1->Width;
// *total_number=0;
// delete contour_x_coordinate,contour_y_coordinate;
chain_code_1 = new short[Image1->Height*Image1->Width]; //globe value
double start,end,tol_time;
start=clock();
int *count=new int(0);
short *count1=new short(0);
int *count2=new int(0);
int *data=new int [8];
int *range=new int(2*(Image1->Width+Image1->Height));
int *x_coordinate=new int[*range];
int *y_coordinate=new int[*range];
int *now_x_coor=new int(0);
int *now_y_coor=new int(0);
int *new_coor=new int[2];
int *the_s_x=new int(0);
int *the_s_y=new int(0);
int *the_l_x=new int(0);
int *the_l_y=new int(0);
short *contour_number = new short(0);
Form2->ProgressBar1->Position=2;
for(int y=1;y<Image1->Height-1;y++)
{
for(int x=1;x<Image1->Width-1;x++)
{
*count=0;
*count1=0;
byte *y_ptr =(byte*) Image1->Picture->Bitmap->ScanLine[y];
byte *x_ptr =y_ptr +3*x;
if(x_ptr[0]==0) //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -