for(int j=0;j<thread_counts;j++) {
std::vector<std::string> tmp_lines(lines.begin() + tmp_size * j, lines.begin() + tmp_size * (j + 1));
tmp_threads[j] = std::thread(face_crop_multi, std::ref(tmp_lines), std::ref(faceDetector), std::ref(fp));
}
for(auto &ithread: tmp_threads) {
ithread.join();
}
发现tmp_lines的结果变为乱码,,
原因:tmp_lines是局部变量,在一个循环结束的时候已经被析构,但是引用对象还在访问内存区域,所以出现乱码