title: How can I use OpenCV with Unicode versions of Delphi?
body: <p>I am editing a open source project called <a href="http://delphimagic.blogspot.com/2011/08/reconocimiento-de-caras-con-delphi.html" rel="nofollow">Opencv for Delphi</a> which compiles fine with Delphi 6 , Delphi 2009 and Delphi xe2.</p>
  
  <p>I just removed incompatible  (eg :<code>Application.MainFormOnTaskbar := True;</code>) for the Delphi 6 compilation.</p>
  
  <p>On the run time d6 app works fine without errors, but the rest are compiling well but with run time error when calling <code>cvopencv.dll</code>.</p>
  
  <p>The original project is a Spanish project compiled with Delphi 2007 which works fine.</p>
  
  <p>In the d6 exe i can't read any thing except ??????? but others showing in spanish which means it is a UNICODE problem, when calling <code>cvopencv.dll</code>the error happens.</p>
  
  <p>What can i do to make this project work with Delphi 2009 or higher (still d2009 compiling well)</p>
  
  <p>========================= After David Heffemans Answer =====================</p>
  
  <pre><code>procedure TForm1.Button2Click(Sender: TObject);
  var
  
     file1 : PAnsiChar; // "haarcascade_frontalface_alt.xml";
     file2 : PAnsiChar; //"haarcascade_eye.xml";
     file3 : PAnsiChar; //"haarcascade_upperbody.xml";
     SourceFileName : AnsiString;
     StorageType : Integer;
     ImSize : CvSize;
  
  begin
     memo1.Lines.Clear;
     GetMem(Storage, SizeOf(CvMemStorage));
     SourceFileName:=Edit1.Text;
     StorageType:=0;
     storage:=nil;
     storage :=cvCreateMemStorage(storageType);
     file1 := PAnsiChar(ExtractFilePath(Application.ExeName)+'haarcascade_frontalface_alt.xml');
     file2 := PAnsiChar(ExtractFilePath(Application.ExeName)+'haarcascade_eye.xml');
     file3 := PAnsiChar(ExtractFilePath(Application.ExeName)+'haarcascade_upperbody.xml');
  
     cascade_f := cvLoad(file1, nil, nil, nil);
     cascade_e := cvLoad(file2, nil, nil, nil);
     cascade_ub := cvLoad(file3, nil, nil, nil);
  
     if cascade_f=nil then ShowMessage('Íå ìîãó çàãðóçèòü êàñêàä Face');
     if cascade_e=nil then ShowMessage('Íå ìîãó çàãðóçèòü êàñêàä Eye');
     if cascade_ub=nil then ShowMessage('Íå ìîãó çàãðóçèòü êàñêàä UpperBody');
  
     img := cvLoadImage(PAnsiChar(AnsiString(SourceFileName)), 1);
  
     cvNamedWindow((PAnsiChar(AnsiString(Edit1.Text))), 1);
  
     detectEyes(img);
     cvShowImage(PAnsiChar(AnsiString(SourceFileName)), img);
  
  end;
  
  end.
  </code></pre>