Using OpenCV with Embarcadero Delphi 10.3.3 (Object Pascal)

Hello to all forum members,

I’m new to the forum and also a newbie to OpenCV. As a development system I almost exclusively use Embarcadero Delphi 10.3.3 (sometimes C++ Builder). So far I have already successfully integrated several external C libraries into Delphi. As I heard, OpenCV is now developed in C ++. Unfortunately I 'm not aware of any possibility to use C ++ classes in Delphi. On Github there is a Delphi wrapper for OpenCV, but unfortunately only for version 2. Does anyone know a possibility to use current versions of openCV with Delphi or are there efforts on the part of the developers of openCV to publish C interfaces again?

Thx in advance.

Greetings
Rob

C interfaces will not come back. they were removed deliberately.

if you need something with a C interface, look into OpenVX.

or consider writing a wrapper. the python bindings are a wrapper (automatically generated… but from custom code) that primarily translates between cv::Mat and numpy matrices. it’s basically C++ code that uses OpenCV and presents C functions that extend python. I’m sure you could do something similar.

I can’t believe that Delphi wouldn’t have gained some way of interfacing with C++ libraries… what is this?

this looks like you’ll have to use C++ Builder to build OpenCV, because you’d need C++ Builder for this type of compatibility.

thx for your fast reply
the Embarcadero blog “Mixing Delphi and C++” refers to the fact that it is possible
to include C ++ Builder source code files in delphi projects but no compiled .obj files

the Packt article (i have the whole book btw) describes the creation of a wrapper

I’ve already tried to compile the openCV sources in c ++ builder many times, unfortunately without success

thx again for your answer

I suspect that the C# folks face similar problems although they can probably just use the MSVC-built binaries. I haven’t seen a C# “wrapper” that is a straight exposition of OpenCV’s C++. they all come up with their own classes. perhaps that’s due to them being born in the C era of OpenCV and generally little progress/support.

apparently cmake can now target C++ Builder so that should make things easier.

some of the arguments (“intel-donated libraries”) in this thread also apply to GCC/MinGW, but OpenCV builds fine with those

in the same thread I do see someone claim that he got OpenCV v3.x working with some patches so that’s a start

I generated the builds in CMake a few times with “Ninja” settings and so far it works quite well.
But when I then run ninja after a short time I get error messages during compilation.

Here’s the console text:

[1/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jfdctint.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jfdctint.c:
[2/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jfdctfst.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jfdctfst.c:
[3/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jidctflt.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jidctflt.c:
[4/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jquant1.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jquant1.c:
[5/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jidctfst.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jidctfst.c:
[6/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jidctred.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jidctred.c:
[7/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jutils.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jutils.c:
[8/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jmemnobs.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jmemnobs.c:
[9/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jquant2.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jquant2.c:
[10/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jmemmgr.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jmemmgr.c:
[11/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jcarith.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jcarith.c:
[12/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jidctint.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jidctint.c:
[13/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jaricom.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jaricom.c:
[14/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jdarith.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jdarith.c:
[15/1557] Building C object 3rdparty\libjpeg-turbo\CMakeFiles\libjpeg-turbo.dir\src\jsimd_none.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src\jsimd_none.c:
[16/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_codec.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_codec.c:
[17/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_aux.c.obj
FAILED: 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_aux.c.obj
C:\PROGRA~2\EMBARC~1\Studio\20.0\bin\bcc64.exe -D_WIN32_WINNT=0x0601 -I3rdparty\zlib -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\zlib -I3rdparty\libtiff -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff -I3rdparty\libjpeg-turbo -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\crtl” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\sdk” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\rtl” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64” -isystem . -tM -fsigned-char -O0 -g -o3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_aux.c.obj -c C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_aux.c
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_aux.c:
In file included from C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_aux.c:32:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\crtl\math.h:723:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\ymath.h:4:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\yvals.h:10:
C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\xkeycheck.h:44:5: error: keyword defined before including C standard header
#error keyword defined before including C standard header
^
1 error generated.
[18/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_dirinfo.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_dirinfo.c:
[19/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_color.c.obj
FAILED: 3rdparty/libtiff/CMakeFiles/libtiff.dir/tif_color.c.obj
C:\PROGRA~2\EMBARC~1\Studio\20.0\bin\bcc64.exe -D_WIN32_WINNT=0x0601 -I3rdparty\zlib -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\zlib -I3rdparty\libtiff -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff -I3rdparty\libjpeg-turbo -IC:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libjpeg-turbo\src -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\crtl” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\sdk” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\rtl” -isystem “C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64” -isystem . -tM -fsigned-char -O0 -g -o3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_color.c.obj -c C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_color.c
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_color.c:
In file included from C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_color.c:38:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\crtl\math.h:723:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\ymath.h:4:
In file included from C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\yvals.h:10:
C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware64\xkeycheck.h:44:5: error: keyword defined before including C standard header
#error keyword defined before including C standard header
^
1 error generated.
[20/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_compress.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_compress.c:
[21/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_close.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_close.c:
[22/1557] Building C object 3rdparty\libtiff\CMakeFiles\libtiff.dir\tif_dir.c.obj
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
C:\DelphiComps\openCV\4.5.2_B\source\3rdparty\libtiff\tif_dir.c:
ninja: build stopped: subcommand failed.

Did you find a solution? I am now trying to build it but I am ending at exact same point.

@Geont, sad as it is, noone has succeeded, ever.

try to use a better supported compiler, and don’t insist on using opencv from pascal
(there is absolutely NO support for that)

that you can’t access C ++ classes with Delphi is clear, it’s the same the other way round, it doesn’t work if you don’t provide access to Delphi classes in a C wrapper. With a C ++ compiler according to the ISO standard it should look different, or what else does this standard exist for?

it’s not true, that there is absolutely no support for Pascal

this is the NEW openCV for Pascal (Classes)

You should expect more from a moderator, especially if you say something so full-bodied that is not true

I seem to be in the wrong forum here if the only answer I get is “don’t insist on using opencv from pascal”
But that may be due to the ignorance of some of those involved
Have a nice day

1 Like
  • first commit: November 21, 2021
  • 54 commits
  • 6 forks, 18 stars

looks new and not too widely known/used

can’t fault someone for not knowing the future, from a June 2021 viewpoint

I would be happy for all the Delphi/Pascal users if that project delivers what it promises.

edit: oh nice, that person has been working on v2.x bindings too. I guess they would know what they’re doing then.

For everyone who’s interested C++Builder v12.2 is now able to build openCV and here is a link form David Millington from Embarcadero on how to do it:

1 Like