跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[问与答] 求救-qt 转 msvc 后 Opencv 始终打不开视频!

发表于

项目背景:这段时间为实验室做了一个小项目,技术栈原本为 QT+Opencv+Mingw ,一切正常。但因为引入了 onnxruntime 所以转为 msvc2019C++编译器,自此噩梦不断。

问题描述:在 debug 其他问题后,目前遇到一个玄学 bug ,使用 QFileDialog 获取到了 QString 类型的文件路径,在使用 toLocal8Bit 转换为 msvc 编码的标注 string 后 opencv 的 cap.open 始终无法打开文件。我是使用了浑身解数也无法,只能来论坛求助大神了!

问题补充:我尝试过将 FFMPEG 的 dll 复制到可执行软件的同目录,配置系统环境还有重新编译 opencv 等方法,均无效果。

获取文件路径的代码:

    QString videoPath = QFileDialog::getOpenFileName(this, "打开文件", usedPath, tr("视频 (*.avi *.mp4 *.wmv)"));

调用 opencv 的代码:

    cv::String dir = std::string(videoPath.toLocal8Bit());
    // cap.open(videoPath.toStdString());
    cap.open(dir, cv::CAP_FFMPEG);

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.