0

I have a task where I am processing a video stream as a batch of images, I have assigned a pointer and am processing the images as a string initially. This is the part of the code where the error occurs

String *Img_seq;
Img_seq = new string[200].c_str();
Mat src, img, img1, image, img_dst, frame;
double TotalTime = 0.0, AveTime = 0.0;
char imgInPath[256], imgOutPath[256], imgOutPath1[256], imgOutPath2[256], BboxPath[256];
string imgpath;
std::vector<cv::String> filenames;
cv::String folder;

capture >> frame;
stringstream ss;
rectangle(frame, cv::Point(10, 2), cv::Point(100, 20),
    cv::Scalar(255, 255, 255), -1);
ss << capture.get(CV_CAP_PROP_POS_FRAMES);
Img_seq[200] = ss.str();
keyboard = waitKey( 30 );

The error which is occurring is:

error: cannot convert ‘std::__cxx11::string* {aka std::__cxx11::basic_string}’ to ‘cv::String’ in assignment
Img_seq = new string[200].c_str();

what do I do in this case, I am new to this so appoligies for the basic question

MrMaavin
  • 1,611
  • 2
  • 19
  • 30
  • What's the `.c_str()` doing there? What are you expecting it to accomplish? I think you read some more about strings and arrays and pointers in [a good book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Oct 23 '18 at 05:35
  • I read that to assign a pointer for a dynamic memory allocation this was the way to go, have I gone wrong there? – Sarvesh Kumar Malladi Oct 23 '18 at 05:41
  • If you read somewhere that `.c_str()` was useful for this, then you shouldn't trust that source in any matter. Stop guessing, don't listen to rumours, go to the library and get a book, or buy one. – molbdnilo Oct 23 '18 at 05:55

1 Answers1

0
String *Img_seq = new string[200].c_str();

should be

String *Img_seq = new String[200];

or better

std::vector<String> Img_seq(200);