Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:53:12+00:00 2026-06-07T08:53:12+00:00

I have created a sample project in D7 demonstrating that strange issue. It is

  • 0

I have created a sample project in D7 demonstrating that strange issue. It is here:
http://speedy.sh/n9Etr/OpenCV-BugTest.zip

I have a procedure which looks like that:

function Rec (image: PIplImage): String;
begin
  DLL_CALL;
end;

When I call Rec, I get AV on DLL_CALL, but …
If I Add Second parameter to the function:

function Rec (image: PIplImage; Something: String): String;
begin
  DLL_CALL;
end;

Then DLL_CALL succeed.

Variable: ‘Something’ is irrelevant and is not taken anywhere …

Really, I don’t know what is happening …

EDIT:

I use cvSaveImage of openCV library.

function cvSaveImage(const filename: PAnsiChar; const image: pointer): integer; 
    cdecl; external CV_HIGH_GUI_DLL;

All my methods are exported with cdecl param’s call convention.

The complete procedure is:

function TCVR.Rec(image: PIplImage): String;
const
  THRESH = 50;
var
  imgDisorted: PIplImage;
  Storage: PCvMemStorage;
  Squares: PCvSeq;

begin
  imgDisorted := nil;
  result := '';

  Storage := cvCreateMemStorage(0);

  cvSetImageROI(image, cvRect(0, 0, image^.width and -2, image^.height and -2));
  PyrDownUp(image);
  cvSetImageROI(image, cvRect(0, 0, image^.width and -2, image^.height and -2));

  imgDisorted := cvCreateImage(cvSize(image^.width and -2, image^.height and -2), 8, 1);
  cvSaveImage('c:\test.jpg', image); <--- AV here only when I have 1 parameter in my Rec.
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:53:13+00:00Added an answer on June 7, 2026 at 8:53 am

    You’re using 1.0 function definitions with a 2.4.1 DLL version. The function definitions changed, so you’re nearly three years out of date. In particular, cvSaveImage expects three parameters, not just two. An excerpt from the 2.0 release:

    CVAPI(int) cvSaveImage( const char* filename, const CvArr* image,
                            const int* params CV_DEFAULT(0) );
    

    Update your DLL import unit to match the DLL you’re using (or switch to an older version of the library). I’d translate that function to Delphi like this:

    function cvSaveImage(filename: PAnsiChar; image: PCvArr; params: PInteger = nil); cdecl;
    

    Here’s why you get the particular failure you saw:

    The DLL doesn’t know that you’re only passing two parameters, so it reads from what it believes to be the third parameter and interprets it as a pointer to an array of integers. Whatever’s really there probably isn’t a pointer at all, and so you get an access violation.

    Adding another parameter to your Rec function causes it to have four parameters (Self, image, Something, and Result), which forces one of the parameters onto the stack. Since the stack is a little bigger, the DLL ends up reading from a different location. That location probably holds a null pointer, so the DLL doesn’t try to read any array elements, and so the code works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sample project here on github where I created a c++ wrapper
I have opened a sample ASP.NET MVC project. In HomeController I have created a
I created a project Sample Code... here I just paste sample code... much of
I have installed the Vaadin plugin for Eclipse. I created a test sample project,
I have created a sample project in asp .net mvc using vs 2010. In
I've created a sample project to simplify my problem. I have this simple handler:
I'm looking at Apple's MVC Networking sample project and I have found that in
I have created a sample project using ASP.NET MVC 3 Web Application (Razor) template.
I have created a sample c++ project under Visual Studio 2010 with following files.
I have created a MVC SenchaTouch project. I have created a sample application where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.