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. Warning generated on calling the capture slot form QCamera
Forum Updated to NodeBB v4.3 + New Features

Warning generated on calling the capture slot form QCamera

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 340 Views 2 Watching
  • 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.
  • KiraK Offline
    KiraK Offline
    Kira
    wrote on last edited by
    #1

    Hello All,

    I am trying to run the below code :

     QByteArray cameraDevice;
        int cameraId = 1;
        QList<QByteArray> cameradev = QCamera::availableDevices();
        cameraDevice = cameradev[cameraId];
    
        QCamera *camera = new QCamera(cameraDevice);
    
        QString description = camera->deviceDescription(cameraDevice);
        qDebug()<<"Device Name"<< description;
    
        QCameraImageCapture *imageCapture = new QCameraImageCapture(camera);
        camera->setCaptureMode(QCamera::CaptureStillImage);
        camera->start();
    
        QImageEncoderSettings imageSettings;
        imageSettings.setCodec("image/jpeg");
        imageSettings.setResolution(1024,768);
        imageCapture->setEncodingSettings(imageSettings);
    
        imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
    
    
    //    Store image in buffer when captured
         QObject::connect(imageCapture, &QCameraImageCapture::imageCaptured, [=] (int id, QImage img) {
    
             img.save("samplerotated.jpeg","jpeg");
    
    
             QPoint center = img.rect().center();
             QMatrix matrix;
             matrix.translate(center.x(), center.y());
             matrix.rotate(-90);
             QImage dstImg = img.transformed(matrix);
    
             dstImg.save("New.jpeg","jpeg");
    
        });
    
    
        camera->searchAndLock();
        imageCapture->capture();
        camera->unlock();
        qDebug()<< camera->error();
    
    
    

    The code works fine but sometimes generates the following warning.
    QObject::moveToThread: Current thread (0x21d234e1db0) is not the object's thread (0x21d2ceeb370).
    Cannot move to target thread (0x21d234e1db0)

    How to resolve the following warning generated

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you calling moveToThread anywhere in your code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

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