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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:32:34+00:00 2026-06-08T01:32:34+00:00

I am currently converting some OpenCV code from C++ to Java. I can’t use

  • 0

I am currently converting some OpenCV code from C++ to Java. I can’t use JavaCV, as we need the conversion in native Java, not a JNA. At one point in the code, I get the following assignment:

dst[x] = (uchar)(-(kHit >= kForeground));

Where dst is uchar*, kHit and kForeground are ints.

I’ve been unable to find anything about how this works, and Java will not recognize it as an operation. There is an operation on these two variables at another point in the code, and it stores one of two values: 255 or 0.

The code in question comes from opencv/video/src/bgfg_gaussmix.cpp.

  • 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-08T01:32:37+00:00Added an answer on June 8, 2026 at 1:32 am

    In C++ a boolean expression produces one of two values – 0 or 1. When you apply the unary minus - to the result, you get 0 or -1. When you re-interpret -1 as uchar, you get 255.

    You can convert this expression to Java with a conditional:

    dst[x] = (kHit >= kForeground) ? 255 : 0;
    

    Because of branching, it is not going to be as fast as the original one. There’s little you can do about the speed of it, however, as Java lacks abilities to re-interpret boolean values as numerics.

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

Sidebar

Related Questions

I am maintaining some Java code that I am currently converting to C#. The
I'm currently converting some legacy code to create PDF files using iTextSharp. We're creating
I have been converting some code from C++ to C#. My lack of understanding
I currently have some code which grabs some JSON from a site. This is
I'm converting some code that currently uses an XmlWriter to create a document to
I'm currently in the process of converting some small personal web sites from WebForms
I am currently scraping some data from the internet and converting into xml documents.
I'm currently building a converter in C#. My program is converting from/to Decimal, Binary
I am converting some docs to pdf using wkhtmltopdf (currently using perl and the
I'm currently converting our company database application from VB to ASP.NET. This is pretty

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.