[SOLVED] QImage exception
-
@SGaist Yes, you are right. That is what I tried for the first time but the images were displayed wrong in Indexed_8 format that is why I wanted to convert them to RGB32. But I don't think this is the source of my problem. I made 30 measurements again but without updating the QBytearray so the data was always the same and the previous error never came. In my opinion somehow my image data could be wrong sometimes and that is why the conversion fails.
-
Did you find what triggers the error in your data ? Where does it come from ?
-
Only on the first frame ?
-
@SGaist Exactly. After the video streaming starts the error never shows up. I'll try to dump the first frame on the sender side and see what could be wrong with the data and so on. I don't think the problem caused by the QTcpSocket which transfers the frames.
-
@SGaist Finally It seems I could solve the problem. The problem was that my frame receiver side had some issues that caused that unexpected frames could come before the previous transfer finished and that caused that during image conversion the QByteArray that holds the image data could change thus read access violations occurred. After I solved this issue the application have not crashed ever since (~50 measurements).
Thank you very much for your help! The conversations made me thinking more and finally this bug could be eliminated.
Cheers,
Tomzi -
Sir, i am new to QT. So help me to fix this as i want to do the samething like you. I want to show live streming through webcamera...as i am using QTCreater 3.2.2 and QT 4.8 on fedora 20.
sir, i have done recording video and capturing video by using following code. I just call this code by using slots of "capture image" and "record a video":
// For Video:-
system("ffmpeg -f video4linux2 -i /dev/video0 -vcodec mpeg4 -b 12000k -r 25 -t 00:00:55 test12.avi");//For image capture:-
system("fswebcam -s 15 --jpeg 95 --save /abasfc.jpeg");Sir, i just want view this particular item on GUI (On QLabel or something) at the time of capturing image and recording video.. How to do that?
thanks in advance... -
Thank all for your replay,
I solve my problem by using Phonon: :video playerSteps:-
i. Add Phonon::Video Player in ui file. I rename its programing name as "Video Player"
ii. Add one button in that ui file and go to that button slot and adding following code in it:-
// For getting system date and time for video name
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);strftime(buf, sizeof(buf), "%d_%m_%y_%H_%M", &tstruct); qDebug() << "Date and Time: "<<buf;
// For getting static path where video will be stored
QString a = "/home/Working_QT/BackupErrorWorking/DeviceTestVersion1/video/";
a.append(buf);
a.append(".avi");
qDebug() << "a: "<<a;// For giving comlete command as it is accepted as a QString and converted into char(Because konsole command is accepted only char it shows error so we convert it)
QString command = "ffmpeg -f video4linux2 -i /dev/video0 -vcodec mpeg4 -b 500k -r 25 -t 00:01:30 ";
command.append(a);
qDebug() << "Command: "<<command;
char x[200];
strcpy( x, command.toStdString().c_str());// Commaand to sysytem
system(x);
qDebug() << "Command given to system to capture video and name it according to that particular date and time: "<<x;// For playing video through Phonon VideoPlayer
qDebug("Before video recording display");
ui->VideoPlayer->play(Phonon::MediaSource(a));
qDebug("After video recording display");iii. Included #include <time.h> // Required for giving video file name according to date and time
and #include <qdebug.h>
iv. Make changes in .pro fileQT += phonon