groupgets / purethermal1-firmware

Reference firmware for PureThermal 1 FLIR Lepton Dev Kit
MIT License
125 stars 62 forks source link

PureThermal (fw:v1.3.0) . Last pixel invalid value #41

Open mrspirytus opened 3 years ago

mrspirytus commented 3 years ago

Hello,

I have two PureThermal (fw:v1.3.0) (1e4e:0100) that I am using to grab frames. I am developing on Nvidia T4L (Nano) 18.04 with the latest libuvc library build from source and opencv from dep repo libopencv-dev/stable,now 4.1.1-2-gd5a58aa75

I am using the latest libuvc because the previous version sometimes has an issue with a shutdown. (thread join issue). All code involved is c/c++ only.

Anyway, what I noticed is that when I process libuvc for each frame, I wrap it in cv:Mat

    cv::Mat img(frame->height,
                frame->width,
                CV_16UC1,
                reinterpret_cast<uchar*>(frame->data));

When I try to dump each unmodified pixel value from img, the very last pixel always has an invalid value which after converting to C I get a very low temp. Here are few bytes from the last line. Please see attached screenshot.

image (3)

Is this a known issue? Here is a more complete code of how I print hex values from uvc callback

cv::Mat img(frame->height,
            frame->width,
            CV_16UC1,
            reinterpret_cast<uchar*>(frame->data));

cout << mat.cols << "x" << mat.rows << "x" << mat.depth() << std::endl;

vector<int16_t> array;
std::stringstream ss;

for(auto r(0); r < mat.rows; ++r) {
    ss.str("");
    for(auto c(0); c < mat.cols; ++c) {
        uint16_t val = *(uint16_t*)mat.ptr(r, c);
        ss << std::setw(4) << std::setfill('0') << std::hex
            << std::uppercase << val << " ";

        //val = ((int16_t)(val - 27315)) / 10;
        //ss << val << " ";
        array.push_back(val);
    }
    cout << ss.str() << std::endl;
}
zhaocundang commented 1 year ago

me too!