rodizio1 / EZ-WifiBroadcast

Affordable Digital HD Video Transmission made easy!
GNU General Public License v2.0
825 stars 200 forks source link

Use with Thermal Expert Q1 #118

Closed wstoettinger closed 5 years ago

wstoettinger commented 6 years ago

Hey!

I'm trying to transmit a thermal image using the Thermal Expert Q1. My test system is up and running (transmitting the raspicam stream works fine).

My test setup: two RPis with a Alfa AWUS036NHA each, sufficient power supply, a monitor and ethernet connection for development purposes.

Now the next step would be to read out the stream of the thermal camera. I have successfully initialized the camera and saved images to the disc with a normal raspbian installation (using libpng), however, when I compile and run the program on the wifibraodcast image I keep getting an "illegal instruction" error when initializing the camera.

I'm using the following driver which works fine on raspbian: https://drive.google.com/open?id=1OcPKFwdkWN9RxaocGh8vI-k9ve-eLDxh

before I install the driver, i run:

sudo apt-get install -y libudev-dev libusb-dev

and before I compile i export the LD_LIBRARY_PATH variable (which i also put into the .profile file):

LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH

The install script of the driver itself performs some "magic" ... it seems that bitecode and script are stored within one file ... apparently generated with a tool called makeself which I don't know ... but it works on raspbian (on the same board and camera) so it shouldn't be a hardware issue.

here is my code te.cpp (which is mostly the demo code of the camera documentation):

#include <iostream>
#include "i3system/i3system_TE.h"

using namespace i3;
using namespace std;

int main()
{   
    // Scan connected TE.
    SCANINFO *pScan = new SCANINFO[MAX_USB_NUM];
    ScanTE(pScan);
    int hnd_dev = -1;
    for(int i = 0; i < MAX_USB_NUM; i++){
        if(pScan[i].bDevCon){
            hnd_dev = i;
            break;
        }
    }
    delete pScan;

    // Open Connected Device
    if(hnd_dev != -1){
        cout << "TE found" << endl;
        TE_B *pTE = OpenTE_B(I3_TE_Q1, hnd_dev);
        bool exit = false;
        if(pTE){
            cout << "TE Opened" << endl;
            // Read Flash Data
            if(pTE->ReadFlashData() == 1){
                cout << "Read Flash Data" << endl;
                int width = pTE->GetImageWidth(), height = pTE->GetImageHeight();
                unsigned short *pImgBuf = new unsigned short[width*height];
                for(int i = 0; i < 10; ++i){
                    // Get Image Data
                    if(pTE->RecvImage(pImgBuf)){
                        cout << "Image Received" << endl;
                        // Get Tamperature at (x, y)
                        int x = 100, y = 100;
                        float temp = pTE->CalcTemp(x, y);
                        cout << "Temperature = " << temp << endl;
                    }
                    else{
                        cout << "Image not received" << endl;
                    }
                }
                delete pImgBuf;
            }
            else{
                cout << "Fail to Read Flash Data" << endl;
            }
            // Close Device
            pTE->CloseTE();
            cout << "Close Usb" << endl;
        }
        else{
            cout << "Open Failed" << endl;
        }
    }
    else{
        cout << "Device Not Connected" << endl;
    }
    return 0;
}

my makefile looks like this:

te:
  g++ te.cpp `pkg-config libusb-1.0 --libs --cflags` `libpng-config --ldflags --cflags` -L/usr/local/lib -li3system_usb_32 -li3system_te_32 -o te

the output I get when running the program:

TE found
TE Opened
Illegal instruction

So the error seems to happen within the ReadFlashData() function.

I then followed the instructions here.

The output of gdb is:

Core was generated by `./te'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x76e0e9ea in i3::Q1_B_Impl::ReadFlashMultiOffset() () from /usr/local/lib/libi3system_te_32.so.2

That's how far I got so far and would appreciate some ideas on how to proceed.

Maybe something a different kernel or kernel setting could fix?

Thanks a lot!

careyer commented 6 years ago

Hi Wolfgang,

nice camera! Did not know about the Thermal Expert Q1 yet. May I ask: What framerate can it support at max resultion?

I did something similar some time ago with a FlirOne for Android and stumbled upon some challenges as well. You might find some valueable information here: #71

Here are a few things that come to my mind:

WBC is a great platform to stream multiple video sources of any kind at the same time. If you are planning to do so please be aware that usage of the "Port" parameter -p in rx and tx is a bit tricky as of 1.6RC5. Memory initialization changed from RC3 to RC5 in a way that I have not been able to properly comprehend yet.

Usage of my solution is on a Reconnaissance & Inspection drone. The looks of it might be evil but it's made for good. (e.g. save fawns during harvest operations) What is your usecase?

wstoettinger commented 6 years ago

Hey @careyer,

thanks a lot for your quick response!

yea, I dug deep to find the Thermal Expert Q1. The internet is full of underperforming and overpriced Flir products and associated projects. The similar priced FlirOne (not the pro) has a 80x60 px resolution compared to the 384x288 ... thats 23 times the resolution! simply disappointing.

concerning your remarks: a) the driver comes pre-compiled for Linux (they provide both ARM and Intel drivers with 64 and 32 bit versions) and it works on stock raspbian. I might try to contact them to get the source but not sure if they are eager to share. b) thanks, i'll check that!

my use case is very similar: to protect and save animals during harvesting operations!

I have mounted the camera (together with wifi card, rpi and battery) on 3d printed mounts to my mavic pro. The weight (250 gram) seems to be low enough for it to fly up to 20 minutes. i'll post images as soon as I got it to work properly ;)

careyer commented 6 years ago

You are welcome. I use a FlirOne Gen2 (discontinued)... it uses a Lepton3 sensor with 160x120. (Same as the new FlirOne Gen3 Pro). The new FlirOne Gen3 "Standard" (only 80x60) is indeed disappointing especially considering that the Gen3 Standard is the same price as the way better Gen2 (with twice the resolution) was. Mind-boggling. You did not mention the frame rate? FlirOne is only 9Hz for all models due to export restrictions.

Happy to hear that we have the same usecase. Do you mind: Where are you from?

wstoettinger commented 6 years ago

I think the export version is 9 Hz as well, the sensor is capable of 30 Hz as far as I remember ... so there might be a way to get around this with a firmware hack or a "black market version" ;)

bortek commented 5 years ago

I am trying to clean up the clutter, Can you please close this issue if not needed anymore. Thanks!

0mnibus commented 5 years ago

You can describe in detail how you managed to get the stream from the thermal expert module. I am new to Linux and would like to get an image from my Thermal expert on a raspberry pi. If you can write instructions step by step. I am familiar with the terminal in Linux. You can use my mail.