線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1087
推到 Plurk!
推到 Facebook!

Error Writing output file

尚未結案
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-10-16 10:12:31 IP:140.112.xxx.xxx 未訂閱
各位好:    我只是再撰寫連續影像相加的程式,可是不知道為何出現此錯誤訊息,不知各位有無此經驗? 謝謝~
 
for (int h=0;hScanLine[h];
  for (int w=0;w     
        
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-10-17 15:09:29 IP:61.59.xxx.xxx 未訂閱
what's ADF ????
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-10-19 20:54:54 IP:140.112.xxx.xxx 未訂閱
ADF 只是變數名稱 [320][240]的矩陣。 ADF[w][h]=floor((ptr[w*3] ptr[w*3 1] ptr[w*3 2])/3); 發表人 - yplin 於 2004/10/19 20:56:36
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-10-19 21:12:31 IP:221.169.xxx.xxx 未訂閱
你這段沒用到檔案了啊。 你還有那些東東沒貼上來????
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-10-19 21:38:08 IP:140.112.xxx.xxx 未訂閱
不好意思,程式如下: 若將此程式mark掉,其程式會出現一樣的錯誤(Error Writing output file ),原本可執行的程式便會失敗。    
 
ADF [320][240];
//-------------------------
for (int h=0;hScanLine[h];
  for (int w=0;w        發表人 - yplin 於 2004/10/19  21:39:41
        
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-10-22 09:22:55 IP:221.169.xxx.xxx 未訂閱
這些都沒用到檔案咩。 找找看你那邊有用到檔案啦。
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-10-22 09:54:28 IP:140.112.xxx.xxx 未訂閱
不好意思。 下面是完整的程式: 謝謝你的回覆~    
 // initiate the vale of coefficients
#define Cap_width     80
#define Cap_height    60
#define WIDTH         320
#define HEIGHT        240    // define the parameters of captured video
CAPSTATUS         CapStatus;
CAPTUREPARMS      CapParms;
CAPDRIVERCAPS     CapDrvCaps;
HWND              hCapWnd;
int               FramePerSec=30;    // Bitmap format
static BITMAPINFOHEADER BitmapHead;
static BITMAPINFO BitmapInfo;
static BITMAPFILEHEADER BitmapFileHead;
int               BIHsize;    // define the subfunctions
LRESULT CALLBACK FrameCallBack( HWND hwnd, Longint lpvhdr );    // Image subtraction
int FrameInterval=4;
int Frames=1;
int ADF[WIDTH][HEIGHT];
int REF[WIDTH][HEIGHT];    //***************************************************************************    TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{    }
//---------------------------------------------------------------------------    void __fastcall TForm1::Disconnect_buttonClick(TObject *Sender)
{
  capCaptureAbort(hCapWnd);
  capDriverDisconnect(hCapWnd);
  capSetCallbackOnVideoStream(hCapWnd,NULL);
  DestroyWindow(hCapWnd);      // initiate the color of image  to be black
  Image1->Canvas->Brush->Color=(TColor) 0x000000;
  Image1->Canvas->FillRect(Form1->ClientRect);
}
//---------------------------------------------------------------------------    void __fastcall TForm1::connect_buttonClick(TObject *Sender)
{
    hCapWnd = capCreateCaptureWindow("Capture Window",
                                     WS_CHILD | WS_VISIBLE,
                                     0,0,Cap_width,Cap_height,
                                     Panel1->Handle,
                                     (int) 0);
    bool connect = false;
    for(int i=0;i<10;i  )
    {
      connect=capDriverConnect(hCapWnd,i);
      if( connect ) break;
    }
    if( !connect )
      ShowMessage("Connection with webcam is failure");        capCaptureGetSetup(hCapWnd ,&CapParms, sizeof(CapParms));
    CapParms.dwRequestMicroSecPerFrame=33334;
    capCaptureSetSetup(hCapWnd ,&CapParms, sizeof(CapParms));        capGetStatus(hCapWnd , &CapStatus , sizeof(CapStatus));
    CapStatus.uiImageWidth=Cap_width;
    CapStatus.uiImageHeight=Cap_height;        capPreviewRate(hCapWnd,1000/FramePerSec);
    capPreviewScale(hCapWnd,true);
    capPreview(hCapWnd,true);        BIHsize=capGetVideoFormatSize( hCapWnd );
    capGetVideoFormat( hCapWnd, &BitmapHead, BIHsize);
    BitmapInfo.bmiHeader=BitmapHead;
    BitmapInfo.bmiHeader.biWidth=Cap_width;
    BitmapInfo.bmiHeader.biHeight=Cap_height;
    BitmapInfo.bmiHeader.biBitCount=24;
    BitmapInfo.bmiHeader.biSize=230400;
    capGetVideoFormat( hCapWnd, &BitmapInfo, capGetVideoFormatSize(hCapWnd));
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Start_buttonClick(TObject *Sender)
{      capSetCallbackOnFrame(hCapWnd, &FrameCallBack);    }
//---------------------------------------------------------------------------    void __fastcall TForm1::Stop_buttonClick(TObject *Sender)
{
  capSetCallbackOnFrame (hCapWnd, NULL);
}
//---------------------------------------------------------------------------    LRESULT CALLBACK FrameCallBack( HWND hCapWnd, Longint lpvhdr )
{
   LPVIDEOHDR VideoStr;
   VideoStr=LPVIDEOHDR(lpvhdr);
   byte *ptr,*ptr1,*ptr2,*ptr3,*ptr4,*ptr5,*ptr6;
   Graphics::TBitmap *FrameBmp=new Graphics::TBitmap();
   FrameBmp->Width=WIDTH;
   FrameBmp->Height=HEIGHT;
   FrameBmp->PixelFormat=pf24bit;;       int k=0;
   for (int h=0;hScanLine[HEIGHT-h-1];
      for (int w=0;w < 3*WIDTH; w=w 3,k=k 3)
      {
         ptr[w]=  (VideoStr->lpData)[k];
         ptr[w 1]=(VideoStr->lpData)[k 1];
         ptr[w 2]=(VideoStr->lpData)[k 2];
      }
   }
   Form1->Image1->Picture->Assign(FrameBmp);       //-----------------------------------------------------
   if  (Frames==1 ||Frames%FrameInterval==0)
   {
     Graphics::TBitmap *RefBmp=new Graphics::TBitmap();
     RefBmp->Width=WIDTH;
     RefBmp->Height=HEIGHT;
     RefBmp->PixelFormat=pf24bit;         int k1=0;
     for (int h=0;hScanLine[HEIGHT-h-1];
      for (int w=0;wlpData)[k1] (VideoStr->lpData)[k1 1] (VideoStr->lpData)[k1 2])/3);
         ptr1[3*w]=REF[w][HEIGHT-h-1];
         ptr1[3*w 1]=REF[w][HEIGHT-h-1];
         ptr1[3*w 2]=REF[w][HEIGHT-h-1];
      }
     }
     Form1->Image3->Picture->Assign(RefBmp);
     delete (RefBmp);
   }
   //--------------------------------------------------------
   Graphics::TBitmap *DiffBmp=new Graphics::TBitmap();
   DiffBmp->Width=WIDTH;
   DiffBmp->Height=HEIGHT;
   DiffBmp->PixelFormat=pf24bit;       int DiffValue;
   for (int h=0;hScanLine[h];
      ptr3=(byte *)DiffBmp->ScanLine[h];
      for (int w=0;wImage2->Picture->Assign(DiffBmp);
   delete (FrameBmp);
   delete (DiffBmp);       Frames  ;
   return(1);
}
//-------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  }
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-10-22 14:06:28 IP:221.169.xxx.xxx 未訂閱
那請問一下。你在幹那一個壞事時。出現這個error??? 不會是一開始就出現。什麼都沒按吧。
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-10-22 15:25:34 IP:220.135.xxx.xxx 未訂閱
FrameBmp->Width=WIDTH; FrameBmp->Height=HEIGHT; FrameBmp->PixelFormat=pf24bit; 把這三行調換一下 FrameBmp->PixelFormat=pf24bit; FrameBmp->Width=WIDTH; FrameBmp->Height=HEIGHT; --- FrameBmp->PixelFormat=pf24bit;; <---多了一個冒號
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-10-22 15:40:13 IP:140.112.xxx.xxx 未訂閱
我已經把此三行程式碼調換,但錯誤訊息還是存在。 不過,謝謝你的回覆~
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#11 引用回覆 回覆 發表時間:2004-10-22 15:43:14 IP:140.112.xxx.xxx 未訂閱
一開始程式執行時都可正常執行,可是我加入了上述的運算式後,即出現錯誤訊息。將其外加程式mark掉後,錯誤訊息依然存在。 謝謝你的回覆~
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#12 引用回覆 回覆 發表時間:2004-10-22 16:18:18 IP:220.135.xxx.xxx 未訂閱
引言: 一開始程式執行時都可正常執行,可是我加入了上述的運算式後,即出現錯誤訊息。將其外加程式mark掉後,錯誤訊息依然存在。 謝謝你的回覆~
請你標明一下,外加程式是哪一部分,原始程式是哪部分
yplin
一般會員


發表:9
回覆:16
積分:5
註冊:2004-08-07

發送簡訊給我
#13 引用回覆 回覆 發表時間:2004-10-22 16:25:06 IP:140.112.xxx.xxx 未訂閱
引言: 不好意思。 下面是完整的程式: 謝謝你的回覆~
 // initiate the vale of coefficients
#define Cap_width     80
#define Cap_height    60
#define WIDTH         320
#define HEIGHT        240    // define the parameters of captured video
CAPSTATUS         CapStatus;
CAPTUREPARMS      CapParms;
CAPDRIVERCAPS     CapDrvCaps;
HWND              hCapWnd;
int               FramePerSec=30;    // Bitmap format
static BITMAPINFOHEADER BitmapHead;
static BITMAPINFO BitmapInfo;
static BITMAPFILEHEADER BitmapFileHead;
int               BIHsize;    // define the subfunctions
LRESULT CALLBACK FrameCallBack( HWND hwnd, Longint lpvhdr );    // Image subtraction
int FrameInterval=4;
int Frames=1;
int ADF[WIDTH][HEIGHT];
int REF[WIDTH][HEIGHT];    //***************************************************************************    TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{    }
//---------------------------------------------------------------------------    void __fastcall TForm1::Disconnect_buttonClick(TObject *Sender)
{
  capCaptureAbort(hCapWnd);
  capDriverDisconnect(hCapWnd);
  capSetCallbackOnVideoStream(hCapWnd,NULL);
  DestroyWindow(hCapWnd);      // initiate the color of image  to be black
  Image1->Canvas->Brush->Color=(TColor) 0x000000;
  Image1->Canvas->FillRect(Form1->ClientRect);
}
//---------------------------------------------------------------------------    void __fastcall TForm1::connect_buttonClick(TObject *Sender)
{
    hCapWnd = capCreateCaptureWindow("Capture Window",
                                     WS_CHILD | WS_VISIBLE,
                                     0,0,Cap_width,Cap_height,
                                     Panel1->Handle,
                                     (int) 0);
    bool connect = false;
    for(int i=0;i<10;i  )
    {
      connect=capDriverConnect(hCapWnd,i);
      if( connect ) break;
    }
    if( !connect )
      ShowMessage("Connection with webcam is failure");        capCaptureGetSetup(hCapWnd ,&CapParms, sizeof(CapParms));
    CapParms.dwRequestMicroSecPerFrame=33334;
    capCaptureSetSetup(hCapWnd ,&CapParms, sizeof(CapParms));        capGetStatus(hCapWnd , &CapStatus , sizeof(CapStatus));
    CapStatus.uiImageWidth=Cap_width;
    CapStatus.uiImageHeight=Cap_height;        capPreviewRate(hCapWnd,1000/FramePerSec);
    capPreviewScale(hCapWnd,true);
    capPreview(hCapWnd,true);        BIHsize=capGetVideoFormatSize( hCapWnd );
    capGetVideoFormat( hCapWnd, &BitmapHead, BIHsize);
    BitmapInfo.bmiHeader=BitmapHead;
    BitmapInfo.bmiHeader.biWidth=Cap_width;
    BitmapInfo.bmiHeader.biHeight=Cap_height;
    BitmapInfo.bmiHeader.biBitCount=24;
    BitmapInfo.bmiHeader.biSize=230400;
    capGetVideoFormat( hCapWnd, &BitmapInfo, capGetVideoFormatSize(hCapWnd));
}
//---------------------------------------------------------------------------    void __fastcall TForm1::Start_buttonClick(TObject *Sender)
{      capSetCallbackOnFrame(hCapWnd, &FrameCallBack);    }
//---------------------------------------------------------------------------    void __fastcall TForm1::Stop_buttonClick(TObject *Sender)
{
  capSetCallbackOnFrame (hCapWnd, NULL);
}
//---------------------------------------------------------------------------    LRESULT CALLBACK FrameCallBack( HWND hCapWnd, Longint lpvhdr )
{
   LPVIDEOHDR VideoStr;
   VideoStr=LPVIDEOHDR(lpvhdr);
   byte *ptr,*ptr1,*ptr2,*ptr3,*ptr4,*ptr5,*ptr6;
   Graphics::TBitmap *FrameBmp=new Graphics::TBitmap();
   FrameBmp->Width=WIDTH;
   FrameBmp->Height=HEIGHT;
   FrameBmp->PixelFormat=pf24bit;;       int k=0;
   for (int h=0;hScanLine[HEIGHT-h-1];
      for (int w=0;w < 3*WIDTH; w=w 3,k=k 3)
      {
         ptr[w]=  (VideoStr->lpData)[k];
         ptr[w 1]=(VideoStr->lpData)[k 1];
         ptr[w 2]=(VideoStr->lpData)[k 2];
      }
   }
   Form1->Image1->Picture->Assign(FrameBmp);       //-----------------------------------------------------
   if  (Frames==1 ||Frames%FrameInterval==0)
   {
     Graphics::TBitmap *RefBmp=new Graphics::TBitmap();
     RefBmp->Width=WIDTH;
     RefBmp->Height=HEIGHT;
     RefBmp->PixelFormat=pf24bit;         int k1=0;
     for (int h=0;hScanLine[HEIGHT-h-1];
      for (int w=0;wlpData)[k1] (VideoStr->lpData)[k1 1] (VideoStr->lpData)[k1 2])/3);
         ptr1[3*w]=REF[w][HEIGHT-h-1];
         ptr1[3*w 1]=REF[w][HEIGHT-h-1];
         ptr1[3*w 2]=REF[w][HEIGHT-h-1];
      }
     }
     Form1->Image3->Picture->Assign(RefBmp);
     delete (RefBmp);
   }
   //--------------------------------------------------------
   Graphics::TBitmap *DiffBmp=new Graphics::TBitmap();
   DiffBmp->Width=WIDTH;
   DiffBmp->Height=HEIGHT;
   DiffBmp->PixelFormat=pf24bit;       int DiffValue;
   for (int h=0;hScanLine[h];
      ptr3=(byte *)DiffBmp->ScanLine[h];
      for (int w=0;wImage2->Picture->Assign(DiffBmp);
   delete (FrameBmp);
   delete (DiffBmp);       Frames  ;
   return(1);
}
//-------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  }
此行即是外加的程式 ADF[w][h]= ADF[w][h] DiffValue;
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#14 引用回覆 回覆 發表時間:2004-10-22 17:16:11 IP:220.135.xxx.xxx 未訂閱
你好:    下圖是把你程式直接執行的結果,左上是ccd擷取的圖片,右上是FrameBmp 左下是DiffBmp,右下是RefBmp。所以...程式沒有錯。請你再檢查看看。    有一點要注意的就是,ccd的擷取格式,因為程式是預設要320x240 所以ccd的擷取格式,最好調成320x240, 24bit, RGB的格式,結果才會正確。    
系統時間:2024-05-14 5:27:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!