Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tcp -video client
QtWS25 Last Chance

Tcp -video client

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VijayMukilan
    wrote on last edited by
    #1

    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 );

       _pSocketVideo->connectToHost(IpList[DeviceNumber],VIDEO_PORT);
    
        connect( _pSocketVideo, SIGNAL(readyRead()), SLOT(VideoDataRead()) );
    

    connect(this,SIGNAL(getFrame(QByteArray)),cameraViewMap[DeviceNumber],SLOT(packFrame(QByteArray)));

    void MainWindow::VideoDataRead()
    {

    VideoData =VideoData+_pSocketVideo->readAll();
    if(firstread)
    {
       byte= MAKEDWORD(VideoData.at(0),VideoData.at(1),VideoData.at(2),VideoData.at(3));
    
        std::cout << byte ;
        firstread=0;
    }
    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;
    frameprocess.lock();
    CopyData=ReadData;
    size=CopyData.size();
    iSync = MAKEDWORD(CopyData.at(0),CopyData.at(1),CopyData.at(2),CopyData.at(3));
    iLength = MAKEDWORD(CopyData.at(4),CopyData.at(5),CopyData.at(6),CopyData.at(7));
    iSize = MAKEDWORD(CopyData.at(8),CopyData.at(9),CopyData.at(10),CopyData.at(11));
    iRows = MAKEDWORD(CopyData.at(12),CopyData.at(13),CopyData.at(14),CopyData.at(15));
    iCols = MAKEDWORD(CopyData.at(16),CopyData.at(17),CopyData.at(18),CopyData.at(19));

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

      memcpy(&FrameBuffer[0],&CopyData,size);
    

    /*
    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);
    fclose(fin);
    */

    // ofcourse i dont have option of using QImage as its from opencv .jpg
    cvMat *decode =cvCreateMat(iRows,iSize,CV_8UC1);
    decode->data.ptr=&FrameBuffer[20];
    frame = cvDecodeImage(decode,CV_LOAD_IMAGE_COLOR);
    if(frame)
    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]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        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.

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved