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

  • Home
  • SEARCH
  • 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 596485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:10:36+00:00 2026-05-13T16:10:36+00:00

I want to use OpenCV’s image processing functions, but not the OpenCV GUI. I’m

  • 0

I want to use OpenCV’s image processing functions, but not the OpenCV GUI. I’m using OpenCV 2.0. I will use either Qt4 or WxWidgets for GUI functions. I compile with VC++ 2008 Express (VC++ 9.0).

I guess it breaks down to two or three questions:

  1. Is it necessary to do something to disable OpenCV’s higui so it does not interfere with the preferred GUI library, and if so, how?

  2. How to convert an OpenCV image into something (bitmap?) that the preferred GUI can display (and perhaps save)?

  3. (Optional) How to convert an image that was loaded using the preferred interface into a form that OpenCV can use?

  • 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-13T16:10:36+00:00Added an answer on May 13, 2026 at 4:10 pm

    Okay. I’ve got the answer to my own question for WxWidgets. One key is not to fight openCV City Hall about RGB sequence. OpenCv really likes “BGR”. WxWidgets uses “RGB” only. The opencv data structure has a field for byte sequence, but it is seldom honored. Even the highGui function (on MS Windows) that displays an image will put up spectacularly blue tangerines if the byte sequence is set to “RGB”. I stubbornly fixed that bug in my local installation, but other operations failed also. So, I just sigh and set the byte order on the opencv side to “BGR” and do the byte swapping as necessary.

    The C++ code below requires that the openCV images that it converts to wxImages are RGB, sequence “BGR”, 8 bit depth and 3 interleaved channels, and have width_step = width*3. The routines don’t check compatibility. Use at your own peril. A ready-for-primetime version would provide for regions of interest (ROI) and other fanciness.

    #include "wx/wx.h"
    #include "cv.h"
    #include "highgui.h" // Optional
    
    
    void copy_and_swap_rb(char *s, char *d, int size) {
        // Copy image data source s to destination d, swapping R and B channels.
        // Assumes 8 bit depth, 3 interleaved channels, and width_step = width*3
        const int step = 3;
        char *end = s + size;
        while (s<end) {
            d[0] = s[2];
            d[1] = s[1];
            d[2] = s[0];
            d += step; s += step;   
        }
    }
    
    void wx2cv(wxImage &wx, IplImage *ipl) {
        // Copy image data from wxWidgets image to Ipl (opencv) image
        // Assumes ipl image has seq "GBR", depth 8, and 3 channels, and 
        // has the same size as the wxImage, and width_step = width*3.
        copy_and_swap_rb((char*)wx.GetData(), ipl->imageData, ipl->imageSize);
    }
    
    void cv2wx(IplImage *ipl, wxImage &wx ) {
        // Copy image data from Ipl (opencv) image to wxImage
        // Assumes ipl image has seq "GBR", depth 8, and 3 channels, and 
        // has the same size as the wxImage, and width_step = width*3.
        copy_and_swap_rb( ipl->imageData, (char*)wx.GetData(),   
                          wx.GetWidth()*wx.GetHeight()*3);
    }
    
    IplImage *cv_from_wx(wxImage &wx) {
        // Return a new IplImage copied from a wxImage. 
        // Must be freed by user with cvReleaseImage().
        IplImage *ret = cvCreateImage(cvSize(wx.GetWidth(), wx.GetHeight()), 
                                      IPL_DEPTH_8U, 3);
        wx2cv(wx, ret);
        return ret;
    }
    
    wxImage wx_from_cv( IplImage *cx) {
        // Return new wxImage copied from a compatible IplImage.
        // Assumes ipl image has seq "GBR", depth 8, and 3 channels
        // Fear not. The copy on return is cheap; does not deep-copy the data.
        wxImage wx(cx->width, cx->height, (unsigned char*) malloc(cx->imageSize), false);
        cv2wx(cx, wx);
        return wx;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.