# Some problems with old OpenCV library and haarcascade

**URL:** https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899
**Category:** Uncategorized
**Tags:** pascal, core, persistence
**Created:** [April 26, 2025, 4:36pm UTC](https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899 "2025-04-26T16:36:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RedCat](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@RedCat](https://forum.opencv.org/u/RedCat)
#### Post date: [April 26, 2025, 4:36pm UTC](https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899/1 "2025-04-26T16:36:04Z")

</div>

Hi to all,  
I’m trying to run face recognition on an old version of the OpenCV library, but when uploading a file haarcascade\_frontalface\_alt.xml the library returns an error with the cvLoad function:

```auto
OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /home/sachin/opencv/sachin/opencv-2.4.10/modules/core/src/persistence.cpp, line 4991
terminate called after throwing an instance of 'cv::Exception'
what(): /usr/src/RPM/BUILD/libopencv2.4-2.4.9.1/modules/core/src/persistence.cpp:4991: error: (-2) The node does not represent a user object (unknown type?) in function cvRead

```

What does the library mean? What kind of user object does she need and where to specify it? I understand that I should use OpenCV version 4.x, but so far I have only managed to figure out the bindings for version 2.x for my programming language (FreePascal). Bindings for version 4 are only in development.

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [April 26, 2025, 6:53pm UTC](https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899/2 "2025-04-26T18:53:55Z")

</div>

what’s the code you’re trying to run? what data (data files) are you trying to run it on? where did you take that file (XML file) from?

generally, a [MRE](https://stackoverflow.com/help/minimal-reproducible-example) helps

---

<div class="post-metadata">

### Author: ![RedCat](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@RedCat](https://forum.opencv.org/u/RedCat)
#### Post date: [April 26, 2025, 7:21pm UTC](https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899/3 "2025-04-26T19:21:50Z")

</div>

Code:

```auto
...
//Imported function
type
TcvLoad = function(const filename: pCvChar; memstorage: pCvMemStorage = Nil; const name: pCvChar = nil;
    const real_name: ppCvChar = nil): Pointer; cdecl;
var
  cvLoad: TcvLoad;
cvLoad := ocvGetProcAddress('cvLoad', coreDLL);
...

//code for load haar
storage := cvCreateMemStorage(0);
  // Load the First HaarClassifierCascade
  if fileexists(extractfilepath(application.exename)+''+cascade_name) then
  Cascade_Name:=extractfilepath(application.exename)+''+cascade_name;
  try
    ClassifierCascade := cvLoad(pCVChar(Cascade_Name));
...

```

the program crashes on the line ClassifierCascade := cvLoad(pCVChar(Cascade\_Name));  
data files getted from github, from OpenCV repo, branch 2.4.(also tried files from archive opencv-2.4.9.zip getted from sourceforge mirror) used file: haarcascade\_frontalface\_alt.xml, also tried haarcascade\_smile.xml and haarcascade\_eye.xml

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [April 27, 2025, 12:47am UTC](https://forum.opencv.org/t/some-problems-with-old-opencv-library-and-haarcascade/20899/4 "2025-04-27T00:47:55Z")

</div>

oh wow, that looks like it’s using the ancient OpenCV 1.x API (a C API). abandon all hope. that stuff was made obsolete with OpenCV version 2.0, which introduced C++ API.

if you abandon freepascal too, and switch to embarcadero stuff, you’ll even find a somewhat active-ish community.

> **[OpenCV: C structures and operations](https://docs.opencv.org/3.4/d2/df8/group __core__ c.html#ga1dafba80b8856132deb18e0ed61e1c2f)**

you didn’t pass anything for `memstorage`. maybe you should. the parameters for a cascade classifier are probably not trivial enough to do without the memstorage.

generally, if you get a violated assertion, you can take that message and look for it in the source code. or see what source file and line is stated in that line of output (`modules/core/src/persistence.cpp:4991`).
