This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

standard camera application crash during get preivew

Other Parts Discussed in Thread: AM3517

Hi Champers,

I am using AM3517 and Android4.0.3 which is last one release from TI for this platform, face one critical issue,

when I try to preview image, i found it never get preview image, but i probed the data lines of CCDC, there is really data pass through.

I debug more and found it is because in thread previewThread, below two flags never become true, why this two flags never become true? I deem this two flags will be automatically set to be 1 by application


if ((mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) ||
(mMsgEnabled & CAMERA_MSG_VIDEO_FRAME)) {

and if i forced this two flags to set to 1, it will crash.

  • Hi,

    Please share the complete logcat output (without any modification to the code) to debug this further.

    Regards,

    Pankaj Bharadiya

  • 8507.logcat_2.txt

    D/CameraHardware( 1081): (zwq)debug Converting YUV to RGB565 with Preview Width - 640 Height - 640
    D/CameraHardware( 1081):
    F/libc ( 1081): Fatal signal 11 (SIGSEGV) at 0x41411002 (code=1)

  • Hi,

    From the log file, it looks like configured preview format and requested preview format is different.

    Please make sure that these sizes are same and buffers allocated for YUYV and RGB formats are of proper size.

    wedden liu1 said:

    D/CameraHardware( 1081): startPreview width:640,height:480
    D/V4L2Camera( 1081): Camera Configure PreviewFormat: w=768 h=480
    D/dalvikvm( 1668): GC_CONCURRENT freed 99K, 4% free 7142K/7367K, paused 1ms+3ms

    Regards,

    Pankaj Bharadiya

  • Hi Pankaj,

    Yes, you are right, I noticed that different also, but I don't know that format is changed unexpectedly, I did set it is 752*480, but setParameters function was called for 7 times, please check another log file attached.

    In that log file, because i didn't force this two flags to set to 1, it cannot preview, so no crahs0245.logcat1.txt

    First of all, please help me check why this two flags was never set to be 1, then, pls help me check  setParameters was called multiple times, thanks

  • Hi.

    I think preview part will be handled by below code. It copies captured buffer to display native window.

    CAMERA_MSG_VIDEO_FRAME flag will bet enabled when you select video recording option from Camera application.


    if(0 == mapper.lock((buffer_handle_t)*hndl2hndl,CAMHAL_GRALLOC_USAGE, bounds, &dst))

    {

    // Get preview frame

    tempbuf=mCamera->GrabPreviewFrame();

    convertYUYVtoRGB565((unsigned char *)tempbuf,(unsigned char *)dst, width, height);

    mapper.unlock((buffer_handle_t)*hndl2hndl);

    mNativeWindow->enqueue_buffer(mNativeWindow,(buffer_handle_t*) hndl2hndl);


    Regards,

    Pankaj Bharadiya

  • Hi Pankaj,

    I agree your declare on CAMERA_MSG_VIDEO_FRAME, but you see,

    if ((mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) ||
    (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME)) {

    this condition is connected by "||", so i think when I launch the camera application, CAMERA_MSG_PREVIEW_FRAME will be enabled, but no, this condition never became true if I don't force to set.

  • Hi Pankaj, I upgraded the new release, but still cannot get preview, it is same reason, I really set the format to 8 bit raw 752*480, but setParameters function is always called for 7 times, and it will automatically change the format to 640*480, I don't know why, can you help dig out why the format is changed?

    I forced to change back the format to 752*480, still cannot get preview, grey_to_yuv42xsp enters into incorrect path.

    Please check the attachment, thanks.5875.logcat4y.txt

  • Hi,

    I think, in V4L2Camera.cpp, Width and height parameters are hard codec. Please correct these parameters as per your need and give it a try.

    https://gitorious.org/rowboat/hardware-ti-omap3/source/d0a71573ee96a51bda3840182ba448011c8f3251:camera/V4L2Camera.cpp#L13

     

    #define IMG_WIDTH_VGA 640

    #define IMG_HEIGHT_VGA 480


    fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;

    fmt.format.code = V4L2_MBUS_FMT_UYVY8_2X8;

    fmt.format.width = IMG_WIDTH_VGA;

    fmt.format.height = IMG_HEIGHT_VGA;

    fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;

    fmt.format.field = V4L2_FIELD_INTERLACED;

    ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);

    if(ret < 0)


    Regards,

    Pankaj Bharadiya

    
    

  • Hi Pankaj,

    I work with  , the person who originally posted with questions. We are trying to get camera sensor using OMAP3 with ICS. Our sensor outputs RAW image of size 752 x 480. 

    I have made necessary modifications to V4L2Camera.cpp and changed the IMAGE_WIDTH and HEIGHT to 752 and 480.

    If you look at the logs that were attached by  , you will see that we are capturing images and the frames are being de queued. 

    Here are the couple of questions I have -

    1) Why do I see SetParameters function being called 7 times? I have also worked with OMAP4 and that doesnt happen on OMAP4. Its only called once.

    2) Why does the value of Width and Height automatically change from 752 x 480 to 640 x 480 after 4 iterations?

    I am pretty sure I have made all the modifications needed to change width and height. But its bizarre that this function is called 7 times?

    3) In PreviewThread() function in CameraHal.cpp, I can see the frame being de queued, but then call back functions are never called and the frames are never sent to the above layer?

    Is TI support incomplete? In OMAP4, when the CameraHAL is inititalized, apart from calling setPArameters, it also calls setcallback function. Just because this callbacks are set, I see the frames being passed above.

    But in OMAP3, if the call backs are not set, even if the frame is ready, CAMERA_MSG_PREVIEW_FRAME & CAMERA_MSG_VIDEO_FRAME are not set. Hence datacb() is not called.

    Can you please throw some light here? We are struggling with this since few months. 

  • Hi Palak,

    Please share you CameraHardware.cpp and V4L2Camera.cpp files along with logcat output.

    Which sensor you are using? What relsolution and color format it supports?

    Regards,

    Pankaj Bharadiya

  • Hi Pankaj,

    Attached is your need, please help us take a look, thanks.3362.CameraHardware.cpp5444.V4L2Camera.cpp0572.logcat5.txt

  • our sensor only support 8 bit raw data output, the resolution is 752*480

  • Hi Pankaj,

    Do you have any update on this?

    -Palak

  • Hello,

      I think the reason for you not being able to see the preview is here -

    From the code snippet below from "CameraHardware.cpp", please try to modify the part highlighted in red.

    if(0 == mapper.lock((buffer_handle_t)*hndl2hndl,CAMHAL_GRALLOC_USAGE, bounds, &dst))
                {
                    // Get preview frame
                    tempbuf=mCamera->GrabPreviewFrame();
                    
    #if defined(USE_SE4500)
            LOGD("Get RAW frame from SE4500 and convert it to YUV\n");
            grey_to_yuv42xsp((unsigned char*) tempbuf,
                           FRAME_WIDTH, FRAME_HEIGHT, PICTURE_WIDTH,
                              (unsigned char*) dst,
                              mPreviewWidth, mPreviewHeight);
    #endif
                    //convertYUYVtoRGB565((unsigned char *)tempbuf,(unsigned char *)dst, width, height);

    Looks like you are not populating the destination buffer which is used for the preview. In your grey_to_yuv42xsp function make sure that the data in "tempbuf" is converted and copied to "dst" buffer.

    Regards,

    Aditya