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

請問如何對影像擷取卡抓到的影像做處理

尚未結案
ee44
一般會員


發表:2
回覆:1
積分:0
註冊:2006-09-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-09-22 21:32:54 IP:163.17.xxx.xxx 訂閱
下面的程式可以正常的將影像顯示在電腦上
但他的方式好像是將影像放到記憶體裡
請問各位前輩
要如何將放在記憶體裡的frame抓出來做處理(如:兩值化、影像相減…等)
或者是直接存成檔案做處理
找了很多資料都找不到要怎麼對DIB做影像處理或者是存成檔案
請各位前輩給小弟些提點!

#include
#pragma hdrstop
#include
#include
#include
#include "multicam.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Initialize variables & tables
m_Channel = 0 ;
m_pCurrent = NULL ;
m_SizeX = 0 ;
m_SizeY = 0 ;
m_pBitmapInfo = 0 ;
m_StatusBarText = "";
m_ChannelState = MC_ChannelState_ORPHAN;
// Initialize driver
McOpenDriver (NULL);
// Activate message box error handling
McSetParamInt (MC_CONFIGURATION, MC_ErrorHandling, MC_ErrorHandling_MSGBOX);
McSetParamStr (MC_CONFIGURATION, MC_ErrorLog, "error.log");

// Create a channel and associate it with the first connector on the first board
McCreate(MC_CHANNEL, &m_Channel);
McSetParamInt(m_Channel, MC_DriverIndex, 0);
McSetParamStr(m_Channel, MC_Connector, "VID1");
// Choose the video standard
McSetParamStr(m_Channel, MC_CamFile, "PAL");
// Choose the pixel color format
McSetParamInt(m_Channel, MC_ColorFormat, MC_ColorFormat_RGB24);

// Choose the acquisition mode
McSetParamInt(m_Channel, MC_AcquisitionMode, MC_AcquisitionMode_VIDEO);
// Choose the way the first acquisition is triggered
McSetParamInt(m_Channel, MC_TrigMode, MC_TrigMode_IMMEDIATE);
// Choose the triggering mode for subsequent acquisitions
McSetParamInt(m_Channel, MC_NextTrigMode, MC_NextTrigMode_REPEAT);
// Choose the number of images to acquire
McSetParamInt(m_Channel, MC_SeqLength_Fr, MC_INDETERMINATE);


// Retrieve image dimensions
McGetParamInt (m_Channel, MC_ImageSizeX, &m_SizeX);
McGetParamInt (m_Channel, MC_ImageSizeY, &m_SizeY);
McGetParamInt (m_Channel, MC_BufferPitch, &m_BufferPitch);

// The memory allocation for the images is automatically done by Multicam when activating the channel.
// We only set the number of surfaces to be created by MultiCam.
McSetParamInt (m_Channel, MC_SurfaceCount, EURESYS_SURFACE_COUNT);

// Enable MultiCam signals
McSetParamInt(m_Channel, MC_SignalEnable MC_SIG_SURFACE_PROCESSING, MC_SignalEnable_ON);
McSetParamInt(m_Channel, MC_SignalEnable MC_SIG_ACQUISITION_FAILURE, MC_SignalEnable_ON);

// Register the callback function
McRegisterCallback(m_Channel, GlobalCallback, this);


// Build RGB24 bitmap info
m_pBitmapInfo = (BITMAPINFO *) new BYTE[sizeof(BITMAPINFO)];
m_pBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_pBitmapInfo->bmiHeader.biPlanes = 1;
m_pBitmapInfo->bmiHeader.biBitCount = 24;
m_pBitmapInfo->bmiHeader.biCompression = BI_RGB;
m_pBitmapInfo->bmiHeader.biSizeImage = 0;
m_pBitmapInfo->bmiHeader.biXPelsPerMeter = 0;
m_pBitmapInfo->bmiHeader.biYPelsPerMeter = 0;
m_pBitmapInfo->bmiHeader.biClrUsed = 0;
m_pBitmapInfo->bmiHeader.biClrImportant = 0;
m_pBitmapInfo->bmiHeader.biWidth = m_BufferPitch / (m_pBitmapInfo->bmiHeader.biBitCount/8) ;
m_pBitmapInfo->bmiHeader.biHeight = -(int)m_SizeY ;

}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
// Set the channel to IDLE before deleting it.
McSetParamInt (m_Channel, MC_ChannelState, MC_ChannelState_IDLE);

// Delete the channel
McDelete (m_Channel);

// Terminate driver
McCloseDriver ();

// Delete bitmap info
if (m_pBitmapInfo) delete m_pBitmapInfo;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::GoClick(TObject *Sender)
{
// Start an acquisition sequence by activating the channel
McSetParamInt(m_Channel, MC_ChannelState, MC_ChannelState_ACTIVE);

StatusBar1->SimpleText = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnFormPaint(TObject *Sender)
{
// Protection
if (m_pCurrent==NULL) return;

// Get DC of the window
HDC hDevice = GetDC (Handle);

// 這邊是顯示的地方,但我不知該如何將裡面的資料擷取出來><
SetDIBitsToDevice (hDevice, 0, 0, m_SizeX, m_SizeY,
0, 0, 0, m_SizeY,
m_pCurrent, m_pBitmapInfo, DIB_RGB_COLORS);

// Release DC
ReleaseDC(Handle,hDevice);

// Display channel info on status bar
// Retrieve the channel state
McGetParamInt (m_Channel, MC_ChannelState, &m_ChannelState);

// Retrieve the frame rate
double frameRate_Hz;
McGetParamFloat(m_Channel, MC_PerSecond_Fr, &frameRate_Hz);
// Display frame rate and channel state
StatusBar1->SimpleText = m_StatusBarText.sprintf("Frame Rate: %.2f, Channel State: %s", frameRate_Hz,
(m_ChannelState == MC_ChannelState_ACTIVE? "ACTIVE" : "NOT ACTIVE"));

}
//---------------------------------------------------------------------------
void WINAPI GlobalCallback (PMCSIGNALINFO SigInfo)
{
if (SigInfo && SigInfo->Context)
{
TForm1* pTForm1 = (TForm1*) SigInfo->Context ;
pTForm1->Callback (SigInfo);
}
}
//---------------------------------------------------------------------------
void TForm1::Callback(PMCSIGNALINFO SigInfo)
{
if (SigInfo->Signal == MC_SIG_SURFACE_PROCESSING)
{
// Update "current" surface address pointer
McGetParamInt (SigInfo->SignalInfo, MC_SurfaceAddr, (PINT32) &m_pCurrent);

//----------------------------------------
//
// Insert the eVision code here.
//
//----------------------------------------

// Post screen refresh message
RECT recpict ;
recpict.left =0;
recpict.top =0;
recpict.right = m_SizeX-1;
recpict.bottom = m_SizeY -1;
InvalidateRect(Handle,&recpict,false);
} else if (SigInfo->Signal == MC_SIG_SURFACE_PROCESSING) {
// Insert your failure handling code here.
}
}
//---------------------------------------------------------------------------
justdo
高階會員


發表:2
回覆:359
積分:222
註冊:2004-08-17

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-10-01 21:33:48 IP:59.105.xxx.xxx 未訂閱
資料存在 m_pCurrent,在Callback函式內會把資料寫到這個成員變數內,裡面是一個陣列存放所有的資料,至於資料的內容格式則依據m_pBitmapInfo
參數來決定,請查閱MSDN有關BITMAPINFOHEADER的說明



friendlly
高階會員


發表:22
回覆:144
積分:103
註冊:2003-04-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2006-10-02 14:08:48 IP:61.64.xxx.xxx 未訂閱

你用的是哪一版MultiCam ,

新舊版有些差異喔...

ee44
一般會員


發表:2
回覆:1
積分:0
註冊:2006-09-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-10-26 16:24:59 IP:163.17.xxx.xxx 訂閱
To justdo:
您好~我知道資料是放在 m_pCurrent裡
但他好像只有資料,bmp的檔頭和調色盤是另外存在m_pBitmapInfo裡
請問我該怎麼將m_pBitmapInfo跟m_pCurrent合併
將其存成一張bmp的影像


To friendlly:
我不知道我是哪一版本的耶
這是我在用的multicam.h
http://four.fsphost.com/strange/multicam.txt
系統時間:2024-05-03 19:47:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!