jakobwilm / slstudio

SLStudio -- Real Time Structured Light. A comprehensive software suite for capturing and reconstructing 3D scenes with a camera-projector pair.
Other
515 stars 194 forks source link

About calibrate #50

Closed MikeDai2020 closed 2 years ago

MikeDai2020 commented 2 years ago

Thanks for your works. I test calibate using the example data, I got: Camera Calibration:

my edit code:

`std::vector readImages(std::string path) { std::vector images; std::vector names; cv::glob(path, names); for(auto name: names) { std::cout << name << std::endl; cv::Mat mat = cv::imread(name, cv::IMREAD_UNCHANGED); images.push_back(mat); } return images; }

void SLCalibrationDialog::on_calibrateButton_clicked() {

// Disable interface elements ui->calibrateButton->setEnabled(false); ui->listWidget->setEnabled(false);

// Stop live view killTimer(liveViewTimer); reviewMode = true; ui->snapButton->setText("Live View");

calibrator->reset();

// Note which frame sequences are used activeFrameSeqs.clear();

QListWidget widget = ui->listWidget; for (int i = 0; i < widget->count(); i++) { QListWidgetItem item = widget->item(i); if (item->checkState() == Qt::Checked) { // vector frameSeq(frameSeqs[i].begin(), // frameSeqs[i].begin() + // calibrator->getNPatterns()); std::string path = rootPath + "/" + item->text().toStdString(); std::cout << "add path:\n" << path << std::endl; std::vector frameSeq = readImages(path); calibrator->addFrameSequence(frameSeq); frameSeqs.push_back(frameSeq); activeFrameSeqs.push_back(i); } } calibrator->checkerSize = ui->checkerSizeBox->value(); calibrator->checkerCols = ui->checkerColsBox->value(); calibrator->checkerRows = ui->checkerRowsBox->value();

// Perform calibration calib = calibrator->calibrate();

// Re-enable interface elements ui->calibrateButton->setEnabled(true); ui->listWidget->setEnabled(true); ui->saveButton->setEnabled(true); }

void SLCalibrationDialog::on_listWidget_itemSelectionChanged() { std::cout << "on_listWidget_itemSelectionChanged" << std::endl; // If selection was cleared if (ui->listWidget->selectedItems().isEmpty()) { std::cout << "empty" << std::endl; return; }

// Stop live view killTimer(liveViewTimer); reviewMode = true; ui->snapButton->setText("Live View");

int currentRow = ui->listWidget->currentRow(); //ui->videoWidget->showFrameCV(frameSeqs[currentRow].back()); std::string path; path = rootPath + "/" + ui->listWidget->currentItem()->text().toStdString(); std::cout << "current path: " << path << std::endl; std::vector names; cv::glob(path, names); if(names.size() > 0) { cv::Mat mat = cv::imread(names[0]); if(!mat.empty()) ui->videoWidget->showFrameCV(mat); } }`

thank you in advance.

jakobwilm commented 2 years ago

Hi Mike.Haveyou verified your projector-camera linearity? This has come up a few times before. Linearity must be good before any hopes can be made. Sincerely

MikeDai2020 commented 2 years ago

thanks for your reply. I just test calibrate with the images provided by you.