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 3756072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:47:44+00:00 2026-05-19T09:47:44+00:00

I need to pass pointer of an array of IplImage ( IplImage extends CvArray

  • 0

I need to pass pointer of an array of IplImage
(IplImage extends CvArray extends Structure implements cloneable) to a function The native code in C is as follows:

cvCalcEigenObjects(
  nTrainFaces,
  (void*)faceImgArr,
  (void*)eigenVectArr,
  CV_EIGOBJ_NO_CALLBACK,
  0,
  0,
  &calcLimit,
  pAvgTrainImg,
  eigenValMat->data.fl);

I tried this:

cvCalcEigenObjects(
  nTrainFaces,
  faceImgArr[0].getPointer(),
  eigenVectArr[0].getPointer(),
  CV_EIGOBJ_NO_CALLBACK,
  0,
                null,
  calcLimit,
  pAvgTrainImg,
  eigenValMat.data.getFloatArray(0, Pointer.SIZE));

but it didn’t work. The declaration of this function in Java is like this:

public static void cvCalcEigenObjects(int i, 
  Pointer pntr, 
  Pointer pntr1, 
  int i1, 
  int 2, 
  Pointer pntr2, 
  cxcore.CvTermCriteria ctc, 
  cxcore.IplImage ii, 
  FloatBuffer fb)
  • 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-05-19T09:47:45+00:00Added an answer on May 19, 2026 at 9:47 am

    Your C prototype is quite unclear but I’ll give you something that’s not obvious at first glance in JNA but that might be the cause of your troubles.


    When dealing with array of structures you need to do something like these :

    // Syntax to get a new empty structure array (4 cells) to pass to a function
    // which will populate it
    MyStructureClass[] incomingStructArray = new MyStructureClass().toArray(4);
    
    // Syntax to transform a standard java array to an array suitable 
    // to be passed to a C function
    MyStructureClass[] standardJavaStructArray = ....
    MyStructureClass[] outgoingStructArray = new MyStructureClass().toArray(standardJavaStructArray);
    

    Now if you wonder why one would need to do so (which is completly crazy from the java point of view) you need to remember you’re not coding Java, you’re coding C

    A standard java array is in fact a void* but a standard C array is a MyStructure*

    If MyStructure uses 12 Bytes in memory :

    • a 4 cell Java array of MyStructureClass uses 16 Bytes (= 4 cell x 4 Bytes per pointer) in memory (not entirely true but let say so ; if all cells != null then an additional 48 Bytes will be used for the MyStructureClass themselves )
    • a 4 cell C array of MyStructure uses 48 Bytes (= 4 cell x 12 Bytes per MyStructure)

    That’s why when using JNA and array of structures you need to be very carefull with what you do, beacause an array of structure is very different from an array of pointers to structure

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

Sidebar

Related Questions

I need to pass a pointer through a scripting language which just has a
I need to pass an array from JavaScript to a page method in C#.
I need to pass multiple arguments to a function that I would like to
I need to pass the $route to its inner function,but failed: function compilePath( $route
How do I pass a pointer value to an array of the struct; For
I am trying to pass a character pointer array as an input from C
I need to send a pointer to a character array to one of my
I am writing an Android app where I need to pass a string array
I need to pass double pointer, which points to the first element of 2D
I need to pass an array as a template type. How can achieve it.

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.