Tcp -video client

  • Hi All,

    New to Qt, started working well.

    I am developing a video client. Server is already sending a data using opencv decodeimage so i got receving .jpg image with header info .

    In the client side i did
    _pSocketVideo = new QTcpSocket( this );

        connect( _pSocketVideo, SIGNAL(readyRead()), SLOT(VideoDataRead()) );


    void MainWindow::VideoDataRead()

    VideoData =VideoData+_pSocketVideo->readAll();
       byte= MAKEDWORD(,,,;
        std::cout << byte ;
    if(byte == VideoData.size())  // here i get the required data in buffer.
        emit getFrame(VideoData);

    Here comes by problem. The received data
    void CameraView::packFrame(QByteArray ReadData)

    unsigned char FrameBuffer[1024*20];
    QByteArray CopyData;

    int i;
    int size;
    iSync = MAKEDWORD(,,,;
    iLength = MAKEDWORD(,,,;
    iSize = MAKEDWORD(,,,;
    iRows = MAKEDWORD(,,,;
    iCols = MAKEDWORD(,,,;

    // all my datas go correct here matching with the server


    here i try to match the server data and client data i am going wrong...
    FILE *fin=fopen("test.bin","wb");
    fwrite(&FrameBuffer[20],sizeof(unsigned char),iSize,fin);

    // ofcourse i dont have option of using QImage as its from opencv .jpg
    cvMat *decode =cvCreateMat(iRows,iSize,CV_8UC1);
    frame = cvDecodeImage(decode,CV_LOAD_IMAGE_COLOR);
    std::cout << "not a vaid frame ";
    // here it goes wrong ?? I am not ware why . My bins dont match... pls help

    [Edited to add @ tags -- mlong]

  • Please add @ around your code. It will format the code.

  • Which is the problem exactly? I think is not so hard to do.
    Remember that the jpg image starts with 0xff 0xd9 and ends with 0xff 0xd8.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.