1

I am working with GenICam library, one of the methods is described as follows: enter image description here

I am using this method to get camera frames. We must provide to pBuffer a pointer, the method will return to our pointer, the memory address where data is stored.

So, I want to obtain the data stored in that memory address, but doing it in this way:

char* image_data = nullptr; 
image_data = new char[1024];
status = gentl->DSGetBufferInfo(datastream_module_handle, new_buffer_event_data.BufferHandle, GenTL::BUFFER_INFO_BASE, &info_datatype, image_data, &info_datasize);
std::cout << **image_data << std::endl;

I am getting this error: error c2100 illegal indirection c++.

I tried to use an auxiliar pointer:

char* image_data = nullptr;
image_data = new char[1024];
char* p_image_data = nullptr;
p_image_data = new char[1024];
status = gentl ... (same method)
p_image_data = *image_data;
std::cout << *p_image_data << std::endl;

but i obtained the following error: error C2440: '=' : cannot convert from char to char *.

How can I obtain the data stored in that memory address ?

2
  • 1
    There's no pointer-to-pointer in your code (nor there's any need for one). Commented Oct 3, 2018 at 8:50
  • You don't need new here, you can just declare char image_data[1024] (or std::array<char, 1024> image_data and pass image_data.data()) Commented Oct 3, 2018 at 9:09

1 Answer 1

3
p_image_data = *image_data;

Should be

p_image_data = image_data;

They both have the same type (char*), so there's no need to dereference. By dereferencing image_data, you get a char again, and that can't be assigned to p_image_data (which is char*), hence the error.

Of course, now you're not copying the data, just setting the pointer. What you probably want instead is:

memcpy(p_image_data, image_data, 1024);

This copies the 1024 chars that image_data points to (after being modified by DSGetBufferInfo) to the 1024 bytes pointed to by p_image_data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.