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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:55:20+00:00 2026-06-05T00:55:20+00:00

How can I correctly convert an OpenCV IplImage to OpenSceneGraph’s osg::Image? This my current

  • 0

How can I correctly convert an OpenCV IplImage to OpenSceneGraph’s osg::Image?

This my current method. But I’m getting incorrect color data.

// IplImage* cvImg is a webcam output image captured using cvQueryFrame(capture)
osg::ref_ptr<osg::Image> osgImage = new osg::Image;
osgImage->setImage(cvImg->width,cvImg->height, 3,
                           GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,
                           (BYTE*)(cvImg->imageData),
                           osg::Image::AllocationMode::NO_DELETE,1);
  • 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-05T00:55:22+00:00Added an answer on June 5, 2026 at 12:55 am

    This is likely an issue involving OpenCV’s native BGR color space. You don’t mention which version of OpenCV you are using, but modern versions define CV_BGR2RGB for use with cvCvtColor. Possibly doing the conversion like this

    IplImage* pImg = cvLoadImage("lines.jpg", CV_LOAD_IMAGE_COLOR);
    cvCvtColor(pImg, pImg, CV_BGR2RGB);
    cvReleaseImage(&pImg);
    

    If you can’t use that another option would be use cvSplit to separate and reorder the channels and then combine them with cvMerge.

    On a side note, I would definitely recommend using the C++ interface as it is much easier memory management, and has more features than the C interface.

    Hope that helps!

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

Sidebar

Related Questions

Not sure if I can explain this correctly, but I am trying to execute
I'm a bit worried if this function sends emails that can be recognized correctly
Need to convert a string to normal datetime format so it can be correctly
How can I convert this Perl code to Groovy? How to bypass confirmation prompts
recently i want to convert some codes from opencv to c#. But I have
I use iconv php function but some characters doesn't convert correctly: ... $s =
Simple C question, how can I correctly and succintly convert milliseconds to seconds. There
How can I convert this text file content into a recursive collection of objects
I can only imagine I'm not searching correctly; this seems like an obvious question
How can I convert this: 26.72773551940918 Into something like this: 22°12'42N The trick here

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.