×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    32

    Capturing QCamera image in a separate thread problem

    I'm trying to catch images using QCamera. Fore more code look at this topic. Now I just want to execute CCameraCallback.Run() method in another thread. Here is the code:
    Code:
    class CCameraCallback
            : public QThread 
            , public IBaseCallback
    {
    
        Q_OBJECT
        Q_INTERFACES(IBaseCallback)
    
    private:
        QCamera*             pCamera;
        QCameraImageCapture* pImageCapture;
    
    public:
        CCameraCallback();
        ~CCameraCallback();
    
        virtual void run();
    
        void SetParam(const QString &, const QVariant &);
    
    private slots:
        void onBufferAvailable(int, const QVideoFrame&);
    
    };
    
    
    void CCameraCallback::Run() {
    
        if (pCamera->state() == QCamera::ActiveState) pCamera->stop();
    
        pCamera->start();
        pCamera->searchAndLock();
    
        pImageCapture->capture();
    
        this->exec();
    
    }
    
    /* rest of the code has not changed */
    Every time run() method executes I'm got "Thread 0xcb0 has panicked. Category: KERN-EXEC; Reason: 0" message. It seems that pCamera->start() crashes. The question is why?

  2. #2
    Registered User
    Join Date
    Feb 2012
    Posts
    32

    Capture image from camera in separate thread

    It there any way to catch camera image in separate tread? I'm trying to do this using code from this topic. I just inherit CCameraCallback from QThread and adding this->exec() to run() method. Now every time i use CCameraCallback->start() i'm got "Thread 0xcb0 has panicked. Category: KERN-EXEC; Reason: 0" error. Can somebody explain why?

    PS: oh, I thought my previous thread didn't added because of error =/ sorry
    Last edited by s.maks; 2012-03-14 at 11:04.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Capture image from camera in separate thread

    Your threads are merged now.

    KERN-EXEC 0 is documented in the Symbian C++ SDK-s, it is about using an invalid handle. Invalid can also mean unavailable, which is the case here: the Symbian camera API does not allow sharing the object between threads. You have to use the camera in the same thread where you are creating it. If you need it in a secondary thread, try creating it there.

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    32

    Re: Capturing QCamera image in a separate thread problem

    I create QCamera and QCameraImageCapture objects in the CCameraCallback class constructor. I also use moveToThread(this) method in constructor. What am I doing wrong?

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Capturing QCamera image in a separate thread problem

    The Symbian C++ part of the QCamera object can not support moveToThread. It will always belong to the thread where it was created.
    Try creating the QCamera object in run() (and invoke exec() after it).

  6. #6
    Registered User
    Join Date
    Feb 2012
    Posts
    32

    Re: Capturing QCamera image in a separate thread problem

    Now when I'm trying to create QCamera object in run() function I got "A data abort exception has occurred accessing 0x48".

    Code:
    void CCameraCallback::run() {
    
        if (!pCamera && !pImageCapture) {
            QByteArray lvCameraDevices = QCamera::availableDevices()[1];    
            pCamera = new QCamera(lvCameraDevices, this); /* error occurs on this line */
            pCamera->setCaptureMode(QCamera::CaptureStillImage);
    
            pImageCapture = new QCameraImageCapture(pCamera); 
            pImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer); 
            pImageCapture->setBufferFormat(QVideoFrame::Format_Jpeg);    
    
            QObject::connect(
                        pImageCapture, SIGNAL( imageAvailable(int, QVideoFrame)),
                        this,          SLOT(onBufferAvailable(int, QVideoFrame))
            );
        }
    
        if (pCamera->state() == QCamera::ActiveState) pCamera->stop();
    
        pCamera->start();
        pCamera->searchAndLock();
    
        pImageCapture->capture();
    
    }
    Last edited by s.maks; 2012-03-15 at 13:13.

  7. #7
    Registered User
    Join Date
    Apr 2009
    Posts
    506

    Re: Capturing QCamera image in a separate thread problem

    Hi

    1. its bad prctice to access pointer w/o checking if its valid:
    pCamera->start();
    pCamera->searchAndLock();

    pImageCapture->capture();
    2. How do you executing run() ?
    Symbian & Qt developer. http://vladest.org

  8. #8
    Registered User
    Join Date
    Feb 2012
    Posts
    32

    Re: Capturing QCamera image in a separate thread problem

    I'm just execute start() method of QThread class. For example:
    Code:
      CCameraCallback lvCameraCallback();
      lvCameraCallback.start();

Similar Threads

  1. Replies: 8
    Last Post: 2012-02-16, 09:40
  2. HELP ME!!!! Problem example capturing image
    By ele.alberti in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2008-10-27, 20:24
  3. Capturing image from secondary camera problem
    By michaelnewyork in forum Symbian
    Replies: 7
    Last Post: 2008-09-08, 08:09
  4. Problem with capturing the second image
    By apashya in forum Streaming and Video
    Replies: 1
    Last Post: 2006-07-01, 10:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×