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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:38:13+00:00 2026-06-07T19:38:13+00:00

i have trouble to convert the following code to javacv: ((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] whats

  • 0

i have trouble to convert the following code to javacv:

((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] whats the tranlation of this?For me it look’s like an array, but the type of value is float.

i don’t know how to set the value to value.

float Saliency::getMean(IplImage * srcArg, CvPoint PixArg, int neighbourhood,    int centerVal)
{
CvPoint P1, P2;
float value;

P1.x = PixArg.x - neighbourhood + 1;
P1.y = PixArg.y - neighbourhood + 1;
P2.x = PixArg.x + neighbourhood + 1;
P2.y = PixArg.y + neighbourhood + 1;

if(P1.x < 0)
    P1.x = 0;
else if(P1.x > srcArg->width - 1)
    P1.x = srcArg->width - 1;
if(P2.x < 0)
    P2.x = 0;
else if(P2.x > srcArg->width - 1)
    P2.x = srcArg->width - 1;
if(P1.y < 0)
    P1.y = 0;
else if(P1.y > srcArg->height - 1)
    P1.y = srcArg->height - 1;
if(P2.y < 0)
    P2.y = 0;
else if(P2.y > srcArg->height - 1)
    P2.y = srcArg->height - 1;

// we use the integral image to compute fast features
value = (float) (
        ((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] +
        ((int*)(srcArg->imageData + srcArg->widthStep*P1.y))[P1.x] -
        ((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P1.x] -
        ((int*)(srcArg->imageData + srcArg->widthStep*P1.y))[P2.x] 
);

value = (value - centerVal)/  (( (P2.x - P1.x) * (P2.y - P1.y))-1)  ;

return value;

}

my translation:

        private float getMean(IplImage srcArg, CvPoint PixArg, int neighbourhood, int centerVal)
        {
         CvPoint P1, P2;
         float value;
         P1.put( PixArg.x() - neighbourhood + 1, PixArg.y() - neighbourhood + 1);
         P2.put( PixArg.x() + neighbourhood + 1, PixArg.y() + neighbourhood + 1);


         if(P1.x() < 0)
             P1.position(0).put(0);
         else if(P1.x() > srcArg.width()- 1)
             P1.position(0).put(srcArg.width()- 1);
         if(P2.x() < 0)
             P2.position(0).put(0);
         else if(P2.x() > srcArg.width()- 1)
             P2.position(0).put(srcArg.width()- 1);
         if(P1.y() < 0)
             P1.position(1).put(0);
         else if(P1.y() > srcArg.height()- 1)
             P1.position(1).put(srcArg.height()- 1);
         if(P2.y() < 0)
             P2.position(1).put(0);
         else if(P2.y() > srcArg.height()- 1)
             P2.position(1).put(srcArg.height()- 1);

         // we use the integral image to compute fast features
         value = (float) (
                 ((int)(srcArg.imageData().get() + srcArg.widthStep()*P2.y()))[P2.x()] +
                 ((int)(srcArg.imageData().get()  + srcArg.widthStep()*P1.y()))[P1.x()] -
                 ((int)(srcArg.imageData().get()  + srcArg.widthStep()*P2.y()))[P1.x()] -
                 ((int)(srcArg.imageData().get()  + srcArg.widthStep()*P1.y()))[P2.x()] );
            );
         float[] bla= (srcArg.imageData().get()+srcArg.widthStep())[P2.x()];
         value = (value - centerVal)/  (( (P2.x - P1.x) * (P2.y - P1.y))-1)  ;

         return value;
        }
  • 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-07T19:38:16+00:00Added an answer on June 7, 2026 at 7:38 pm

    okay, i think the equal translation is this:
    UPDATE:

    private float getMean(IplImage srcArg, CvPoint PixArg, int neighbourhood,
    int centerVal) {
    CvPoint P1 = new CvPoint(), P2 = new CvPoint();
    float value;
    P1.put(PixArg.x() – neighbourhood + 1, PixArg.y() – neighbourhood + 1);
    P2.put(PixArg.x() + neighbourhood + 1, PixArg.y() + neighbourhood + 1);

        if (P1.x() < 0)
            P1.x(0);
        else if (P1.x() > srcArg.width() - 1)
            P1.x(srcArg.width() - 1);
        if (P2.x() < 0)
            P2.x(0);
        else if (P2.x() > srcArg.width() - 1)
            P2.x(srcArg.width() - 1);
        if (P1.y() < 0)
            P1.y(0);
        else if (P1.y() > srcArg.height() - 1)
            P1.y(srcArg.height() - 1);
        if (P2.y() < 0)
            P2.y(0);
        else if (P2.y() > srcArg.height() - 1)
            P2.y(srcArg.height() - 1);
        BytePointer src = new BytePointer(srcArg.getByteBuffer());
    
        int pos1 = (int) srcArg.widthStep() * P2.y();
        int pos2 = (int) (srcArg.widthStep() * P1.y());
        int pos3 = (int) (srcArg.widthStep() * P2.y());
        int pos4 = (int) (srcArg.widthStep() * P1.y());
        value = (float) (src.position(pos1).get(P2.x())
                + src.position(pos2).get(P1.x())
                - src.position(pos3).get(P1.x())
                - src.position(pos4).get(P2.x()));
    
        value = (value - centerVal)
                / (((P2.x() - P1.x()) * (P2.y() - P1.y())) - 1);
        // System.out.println(value);
        return value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble figuring out why a simple division like this one always returns
I have trouble finding way to correctly refactor this code so that there would
I have a Windows CE console application that's entry point looks like this int
I have the following jquery I'd like to convert to prototype. I am having
I have trouble doing this... You may want to get the same result as
Okay, I am having trouble with the following piece of code (in a header
Im having trouble with some conversions, and can´t find whats wrong with the code,
I have the following code $getchats = $api->call(getLatestChats); echo '<pre>'; print_r(array_values($getchats)); echo '</pre>'; which
I have the following C function: unsigned int DJBHash(char* str, unsigned int len) {
I have the following code under a TabConttrols DrawItem event that I am trying

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.