全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2129
推到 Plurk!
推到 Facebook!

DLL 傳輸影像資料問題

答題得分者是:taishyang
small7011
一般會員


發表:19
回覆:34
積分:10
註冊:2007-07-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2017-06-22 01:51:51 IP:118.150.xxx.xxx 未訂閱
下面是包一個可以取得CCD 影像資料DLL檔 ,  我特別把 CCM_IMX214->imgBMP24Buffer 儲存確認影像是有在變化.
而我的問題是 ,我在引用DLL想取得Raw資料時發現取得的影像資料沒有變化 ,一直維持第一次取到的畫面 ,
不知道是否有大大是否可以幫忙,我找好久都沒有找到問題.

[code cpp]
void __stdcall GETRAWDATA(byte *byRAW)
{
UINT nSize = CCM_IMX214->CurrentSensor.width * CCM_IMX214->CurrentSensor.height * 3 1024;

Graphics::TBitmap *Bmp1 = new Graphics::TBitmap();
Bmp1->PixelFormat=pf24bit;
Bmp1->Width=CCM_IMX214->CurrentSensor.width;
Bmp1->Height=CCM_IMX214->CurrentSensor.height;

Graphics::TBitmap *Bmp2 = new Graphics::TBitmap();
Bmp2->PixelFormat=pf24bit;
Bmp2->Width=CCM_IMX214->CurrentSensor.width;
Bmp2->Height=CCM_IMX214->CurrentSensor.height;


memcpy(byRAW ,CCM_IMX214->imgBMP24Buffer,(nSize)*sizeof(byte));

//AnsiString asTemp=AnsiString().sprintf("%p,%p\x0d\x0a",byRAW1,CCM_IMX214->imgBMP24Buffer);
//Application->MessageBox(("記憶體位置=" asTemp).c_str(), "System", MB_OK);


Byte *ptr1,*ptr2;
int i=0;
//
for(int y=0;yHeight;y )
{
ptr1 = (Byte *)Bmp1->ScanLine[y];
ptr2 = (Byte *)Bmp2->ScanLine[y];

for(int x=0;xWidth;x )
{
ptr1[x*3]=CCM_IMX214->imgBMP24Buffer[i];
ptr1[x*3 1]=CCM_IMX214->imgBMP24Buffer[i 1];
ptr1[x*3 2]=CCM_IMX214->imgBMP24Buffer[i 2];

ptr2[x*3]=byRAW[i];
ptr2[x*3 1]=byRAW[i 1];
ptr2[x*3 2]=byRAW[i 2];

i=i 3;
}
}

Bmp1->SaveToFile("Original.bmp");
Bmp2->SaveToFile("COPY.bmp");

delete Bmp1;
delete Bmp2;

}
//---------------------------------------------------------------------------
[/code]

下面是主程式去呼叫DLL函數
[code cpp]

//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{

//OPEN DLLL
insPass= LoadLibrary("MA3D700_DLL.dll");
if(insPass == NULL)
throw "DLL can not loading,please check MA3D700_DLL.dll!";

//int (*pOpen)();
(FARPROC &)pOpen= GetProcAddress(insPass,"OPENDOTHINKEY");

//void (*pGetRawData)(BYTE *);
(FARPROC &)pGetRawData= GetProcAddress(insPass,"GETRAWDATA");

//int (*pClose)();
(FARPROC &)pClose= GetProcAddress(insPass,"CLOSEDOTHINKEY");

if(pOpen== NULL || pClose== NULL ){
FreeLibrary(insPass);
throw "MA3D700_DLL.dll address fail!";
}

}
//---------------------------------------------------------------------------

void __fastcall TForm1::nOpenClick(TObject *Sender)
{
nFile->Enabled=false;

Graphics::TBitmap *Bmp= new Graphics::TBitmap();
Bmp->PixelFormat=pf24bit;
Bmp->Width=4208;
Bmp->Height=3120;

byte *byRAW = new BYTE[Bmp->Width*Bmp->Height*3 1024];

Byte *ptr;

int t=0;
if(pOpen())
{

do{

ZeroMemory(byRAW,sizeof(byRAW));
pGetRawData(byRAW);

//AnsiString asTemp=AnsiString().sprintf("%p,\x0d\x0a",byRAW);
//Application->MessageBox(("記憶體位置=" asTemp).c_str(), "System", MB_OK);

int i=0;
for(int y=0;yHeight;y )
{
Byte *ptr = (Byte *)Bmp->ScanLine[y];
for(int x=0;xWidth;x )
{

ptr[x*3]=byRAW[i];
ptr[x*3 1]=byRAW[i 1];
ptr[x*3 2]=byRAW[i 2];

i=i 3;
}
}

img1->Picture->Bitmap->Assign(Bmp);
img1->Picture->SaveToFile("BMP3.bmp");

}while(1);
}

delete Bmp;
nFile->Enabled=true;

}
//---------------------------------------------------------------------------
[/code]
------
lee
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2017-07-07 18:56:10 IP:59.127.xxx.xxx 未訂閱
試試在Do裡面加Sleep()
系統時間:2024-04-20 22:50:34
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!