0

I have a Qt application in which I open/choose a video file with :

QString fichier=QFileDialog::getOpenFileName(…);

Then, I need to read this video with openCV with :

string str= fichier.toStdString();
const char* c_videoFile=str.c_str();
capture = cvCreateFileCapture(c_videoFile);
if(capture==0){
    //file cannot be open
 }
 else{
     //get frames, ...
 }

The problem is that it doesn't work at all (capture==0) with file name with characters like :

Dziękuję
Påfårö
Русский
キャン#&セル

even with

capture = cvCreateFileCapture("path/to/Русский.mp4");

for example. If I ouput c_videoFile in the console, the name is correct.

How to solve that knowing that I have to use Qt to open the file so I necessarily have a QString to convert into a const char* . Can't openCV deal with that kind of characters?

I tried the answer there imread(openCV),QString unicodes but I get errors "no type named setCodecForCStrings in QTextCodec", "no type named setCodecForTr in QTextCodec", "no member named toAscii in QString". So I think this answer was valid for older version of Qt.

I work on Mac OS 10.8.5, Qt 5.3.1 and openCV 2.4.8. It works on Windows 7.

Community
  • 1
  • 1
SteveTJS
  • 635
  • 17
  • 32
  • 1
    What if you call `capture = cvCreateFileCapture(fichier.toUtf8().data());` – vahancho Oct 14 '15 at 08:29
  • You must understand, what encoding may be accepted by `cvCreateFileCapture` and use corresponding method in `QString` to convert data. – Dmitry Sazonov Oct 14 '15 at 09:13
  • @vahancho It still doesn't work. – SteveTJS Oct 14 '15 at 09:38
  • @SaZ Indeed, but even by passing directly the path as parameter cvCreateFileCapture("/path/to/fileNameWithUnicodeChar.mp4"), it doesn't work so, if the function deals with that, it should work like that, no? – SteveTJS Oct 14 '15 at 09:38
  • I tested on Windows 7, it works with any characters with simply cvCreateFileCapture(fichier.toStdString().c_str()). (Those differences between Mac and Windows are sometimes annoying). So I would say that there is something wrong with openCV and Mac. – SteveTJS Oct 14 '15 at 09:47

0 Answers0