光光
一般會員
發表:19 回覆:19 積分:7 註冊:2004-10-30
發送簡訊給我
|
JerryKuo 你好..
我已經看過了你在本站所po的程式碼,但我還是有些錯誤
你所po出來的是副程式,我想看看你的主程式...不知道方不方便
看怎麼從主程式去call副程式,不知道你的是不是bcb的..... 謝謝你
|
JerryKuo
版主
發表:42 回覆:571 積分:322 註冊:2003-03-10
發送簡訊給我
|
引言:
JerryKuo 你好..
我已經看過了你在本站所po的程式碼,但我還是有些錯誤
你所po出來的是副程式,我想看看你的主程式...不知道方不方便
看怎麼從主程式去call副程式,不知道你的是不是bcb的..... 謝謝你
光光 你好, void traceface(unsigned char **image,int img_w,int img_h,int face_w,int face_h)
就是主程式,只要輸入一個二維陣列空間和長寬呼叫此函數,就會有結果。
看到printf()就應該知道這個程式是純c語言(我在其他回覆文中也有說了)
很明顯的這不能貼到bcb直接執行,很抱歉。所以我不贊成你copy我的程式
去用,程式沒幾行,c語言應該看得懂,觀其行會其意,應該很容易寫出自己
想要的bcb程式。加油。
|
光光
一般會員
發表:19 回覆:19 積分:7 註冊:2004-10-30
發送簡訊給我
|
JerryKuo 你好....
不好意思,我並沒有要copy你的程式...
只是我要應用你的東西而已,另外我用bcb寫的時候發現有錯
所以我才請教你有bcb的程式碼嗎???我是新手 ....謝謝你
|
光光
一般會員
發表:19 回覆:19 積分:7 註冊:2004-10-30
發送簡訊給我
|
JerryKuo 你好.... 不好意思....又來打擾你了,我只是要應用你的程式去做一些東西
所以我先把你的程式改成bcb然後再run但是不知道哪裡改錯了
出現一大堆錯誤,可否請你幫榜看看
.cpp檔
[code]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
unsigned char **image;
int img_w,img_h,face_w,face_h;
unsigned char **ellipsemask;
int maxmatchpoint = 0,matchpoint = 0;
int face_x,face_y;
int i,j;
image = (unsigned char **)malloc(sizeof(unsigned char *)*img_h);
for( i=0 ; i< img_h ; i++)
{
image[i] = new unsigned char[img_w];
for(j=0 ; j< img_w; j++)
{
image[i][j] = 0;
}
}
ellipsemask = GetEllipseMask(face_w,face_h);
for(j=0 ; j0)
{
image[j 13][i 6] = 255; /* ³]©wµêÀÀ¤HÁyªº¦ì¸m¦b (6,13) */
} else image[j 13][i 6] = 0;
}
for(j=0 ; j < (img_h - face_h); j )
for(i=0 ; i < (img_w - face_w); i )
{
matchpoint = SearchMatchPoint(); if(matchpoint > maxmatchpoint)
{
maxmatchpoint = matchpoint;
face_x = i;
face_y = j;
}
}
ShowMessage("The center position of face : x = %d, y = %d\n",face_x,face_y); FreeEllipseMask(); /*free mask memory*/
for(j = 0 ; j < img_h ; j )
free(image[j]); /*free image memory*/
free(image);
}
void __fastcall TForm1::FreeEllipseMask(unsigned char **image,int width,int height)
{
int y; if(image == NULL)
return; for(y = 0 ; y < height ; y )
free(image[y]);
free(image);
} int __fastcall TForm1::SearchMatchPoint(unsigned char **image,unsigned char **mask,int begin_x,int begin_y,int face_w,int face_h)
{ int i,j;
int matchcount = 0; for(j=0 ; j0) /* if run to the ellipsemake edge */
{
/* check the intensity of the pixel */
if(image[j begin_y][i begin_x] > 128)
{ /* Pass, it may be a face edge. add count */
matchcount ;
} }
}
return matchcount;
}
int __fastcall TForm1::GetEllipseMask(int width,int height)
{
//unsigned char **EllipseMask;
int centerx,centery;
double a,b;
int edge_x,edge_y;
int i,j; /* make a EllipseMask memory space*/
EllipseMask = (unsigned char **)malloc(sizeof(unsigned char *)*height);
for( i=0 ; i
#include
#include
#include <Forms.hpp>
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TImage *image;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner);
unsigned char **GetEllipseMask(int width,int height);
__fastcall TForm1:: SearchMatchPoint();
__fastcall TForm1::FreeEllipseMask();
__fastcall TForm1::GetEllipseMask();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 謝謝你
[\code]
|
JerryKuo
版主
發表:42 回覆:571 積分:322 註冊:2003-03-10
發送簡訊給我
|
光光你好: 由於此篇過長,為方便閱讀,請另開主題討論
|