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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:11:56+00:00 2026-06-07T21:11:56+00:00

I would like to access the data within this member function that is static.

  • 0

I would like to access the data within this member function that is static. Right now the member function is static so that I can use it with a third party API written in C that has typdef function pointer for callback purposes. Based on the info below, what is the best way to get around the need to create a static function in order to use the data from the following function member within other member functions of my class that are non-static. Maybe there is a way to still use this static function but still overcome the inability to mix static with non-static variables. My code does works as is but with no ability to access the data in the following callback function.

void TextDetect::vtrCB(vtrTextTrack *track, void *calldata) /*acts as a callback*/
{
/*specifically would like to take data from "track" to a deep copy so that I don't loose   scope over the data withing that struct */

}

In an associated API written in C, there are the following two lines of code that I am forced to use:

 typedef void (*vtrCallback)(vtrTextTrack *track, void *calldata);
 int vtrInitialize(const char *inifile, vtrCallback cb, void *calldata);

Here is the header of my class:

 #include <vtrapi.h>
 #include <opencv.hpp>

 class TextDetect {
const char * inifile;
vtrImage *vtrimage;
int framecount;
 public:
TextDetect();
~TextDetect();
static void vtrCB(vtrTextTrack *track, void *calldata);
int vtrTest(cv::Mat);
bool DrawBox(cv::Mat&);

  };


  TextDetect::TextDetect() : inifile("vtr.ini")
  {
if (vtrInitialize(inifile, vtrCB /*run into problems here*/, NULL) == -1)
    std::cout << "Error: Failure to initialize" << std::endl;
vtrimage = new vtrImage;
framecount = 0;

  }

  void TextDetect::vtrCB(vtrTextTrack *track, void *calldata) /*acts as a callback*/
 {
/*specifically would like to take data from "track" to a deep copy so that I don't loose   scope over the data withing that struct */

 }
  • 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-07T21:11:59+00:00Added an answer on June 7, 2026 at 9:11 pm

    I am not sure I understand your precise situation, but here is the standard idiom for wrapping a C++ method into a C callback API:

    /*regular method*/
    void TextDetect::vtrCB(vtrTextTrack *track)
    {
       // do all the real work here
    }
    
    /*static method*/
    void TextDetect::vtrCB_thunk(vtrTextTrack *track, void *data)
    {
       static_cast<TextDetect *>(data)->vtrCB(track);
    }
    

    and then, assuming the function that should call vtrInitialize is also a TextDetect method, you write the call like this:

       vtrInitialize(inifile, TextDetect::vtrCB_thunk, static_cast<void *>(this));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use WCF RIA Services to access data from my Silverlight
I have a Data Access Layer library that I would like to make portable.
I would like to be able to access data:post.labels from within the header at
I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like
I would like to access a MySQL database using PHP. Can someone please explain
I would like to define access right to Collabnet Subversion Directory with LDAP domain
I would like to use redis to query data from commandline, scripts, web and
We would like to decrypt data stored in Microsoft Access. Without getting into too
I would like to access class variables with for loop, here is my simple
I've got a website hosted on my IIS and I would like to access

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.