Author Topic: Question about FLIR One for Android  (Read 173736 times)

0 Members and 3 Guests are viewing this topic.

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Question about FLIR One for Android
« on: October 04, 2015, 03:12:39 am »
Now that FLIR has finally released it (not just for pre-sale anymore), has anybody managed to make a USB driver for Windows for it yet? I remember with the Seek Thermal imager, somebody managed to (after connecting it to their PC's USB port, via a USB-A to micro-USB cable) create Windows drivers for it, so that it was usable on the PC as a webcam. Has anybody yet managed to do the same thing with the FLIR One for Android, which (like the Seek Thermal) has a micro-USB connector on it?
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #1 on: October 05, 2015, 12:02:50 am »
50 views and no replies? I think there was an entire thread, several pages long, regarding 3rd party drivers for the Seek Thermal imager. I'd think this would be a hot topic, but nobody has replied yet. I'd think somebody would be trying to accomplish the same thing with the FLIR One for Android, but there seems to be little interest, as evidenced by the fact that this thread is on the second page of the Test Equipment section, and yet has no replies (other than the one I'm posting now, for the purpose of putting it back on the first page).
 

Offline encryptededdy

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: nz
Re: Question about FLIR One for Android
« Reply #2 on: October 05, 2015, 01:40:42 am »
I think due to the use of a Lepton sensor, those who are interesting in integrating thermal imaging into some kind of product or for some kind of static PC-connected setup are just waiting for FLIR to officially release the Lepton 3 for sale. We already know PureEngineering/GroupGets has their hands on a Lepton 3 module and developed a USB <-> Lepton 3 interface board. https://vine.co/v/edPq5ZD9aO7



Also I can't see much use in connecting the FLIR One Gen 2 to a PC... with the Seek we could use it to increase image quality, fix the gradient, and get raw data out. However with the FLIR One I doubt there's much to be improved on in terms of IQ (due to FLIR's already heavy image processing done in-module) and it also saves radiometric JPEGs with full raw data.
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #3 on: October 05, 2015, 05:53:52 am »
I think due to the use of a Lepton sensor, those who are interesting in integrating thermal imaging into some kind of product or for some kind of static PC-connected setup are just waiting for FLIR to officially release the Lepton 3 for sale. We already know PureEngineering/GroupGets has their hands on a Lepton 3 module and developed a USB <-> Lepton 3 interface board. https://vine.co/v/edPq5ZD9aO7



Also I can't see much use in connecting the FLIR One Gen 2 to a PC... with the Seek we could use it to increase image quality, fix the gradient, and get raw data out. However with the FLIR One I doubt there's much to be improved on in terms of IQ (due to FLIR's already heavy image processing done in-module) and it also saves radiometric JPEGs with full raw data.

Even so, for those who want a simple way of doing it, without soldering (as you would need to do with the USB interface board you have been speaking of), having an already existing module (like the FLIR One for Android) would be a great thing. Also, you can get raw, unprocessed thermal image, if you create your own reverse engineered driver for the FLIR One for Android on the PC. And I want that raw, unprocessed data, and I don't want to have to use a soldered project board (like the one you were talking about) to do it. Using a PC driver created from info gathered by reverse engineering it the FLIR One for Android, I would be able to use an already assembled thermal module, that costs very little money, and requires absolutely ZERO soldering, in order to capture true thermal images. So consider this thread a request to all reverse engineers out there, to get on with reverse engineering the FLIR One for Android, so that I will be able to use it ultimately as a thermal webcam for doing all kinds of fun experiments.

One of the things about using the official software on an Android device is that it resizes the thermal image prior to embedding it in a JPEG. You see, the "FLIR One for Android"'s actual output is a 160x120 thermal image that comes out of the USB port, and is then processes by the FLIR One app on an Android device. Part of the processing is to interpolate the 160x120 thermal raw pixels to a 320x240 image. This interpolation is done prior to saving in the radiometric JPEG file, but it is done by the app, NOT by the microcontroller in the "FLIR One for Android" hardware (or at least I hope that's the case). If you can reverse engineer the USB communication protocol used by the FLIR One for Android, and then write your own driver for it for a PC, you SHOULD be able to access the truly RAW (160x120) thermal pixels data stream from the device. As nice as it is to have an image that is bigger than 160x120, doubling the resolution to 320x240 is in effect falsifying scientific data, meaning that it's basically useless for anything other than taking thermal pictures for fun. At this point, saving it as a thermometric JPEG image (as if the data was scientifically valid) is a quite deceptive practice. It give the false impression that the data is actually useful for measuring real temperatures. It is not. It only gives you APPROXIMATE temperatures (which any true scientist would laugh at).

But if I can access (via PC drivers, created through reverse engineering), the actual 160x120 raw thermal image data, I will have my hands on actual usable scientific data. And I will be guarantied that the temperatures calculated from this data are completely accurate.

And by the way, I've never heard of a Lepton 3. I haven't even heard of a Lepton 2. I've just heard of a Lepton, and that the new version with double the horizontal and vertical resolution (160x120, instead of 80x60) is still just called the Lepton. FLIR does not seem to number its newer versions of cores. I can't find any official naming of the Lepton 3 on FLIR's website.
« Last Edit: October 05, 2015, 06:01:08 am by Ben321 »
 

Offline encryptededdy

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: nz
Re: Question about FLIR One for Android
« Reply #4 on: October 05, 2015, 06:25:17 am »
Lepton 2 is the 80x60 one we currently have access to. Lepton 3 is the new 160x120 one. They appear to be just internal FLIR names, so you won't find them on the FLIR website. See this document.

At least groupget's previous breakout boards were all sold pre-soldered and ready to use. See: https://groupgets.com/manufacturers/groupgets-labs/products/flir-lepton-breakout-board-v1-4

Here is the full datasheet for Lepton 3: http://media.wix.com/ugd/53cdb6_5191be73d1c943d78d2e1a095cb7f3b8.pdf

According to that, the Lepton 3 does output 160x120 data over voSPI (page 38), so the upscaling must be done in the app or the hardware of the FLIR One.

To be honest, I don't understand your issue with the upscaling. While it's true that native resolution data is the most optimal, if we consider the issues with sharpness on the Lepton's lens (see the FLIR One G2 actual resolution thread) making the sensor only resolve details similarly to a ~120x90 sensor (even though the sensor really is 160x120) and the fact that the Lepton's temperature accuracy is ±2 degrees C, I doubt the upscaling makes any appreciable difference to the observed accuracy of the temperature readings.
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #5 on: October 05, 2015, 06:30:22 am »
Lepton 2 is the 80x60 one we currently have access to. Lepton 3 is the new 160x120 one. They appear to be just internal FLIR names, so you won't find them on the FLIR website. See this document.

At least groupget's previous breakout boards were all sold pre-soldered and ready to use. See: https://groupgets.com/manufacturers/groupgets-labs/products/flir-lepton-breakout-board-v1-4

Here is the full datasheet for Lepton 3: http://media.wix.com/ugd/53cdb6_5191be73d1c943d78d2e1a095cb7f3b8.pdf

According to that, the Lepton 3 does output 160x120 data over voSPI (page 38), so the upscaling must be done in the app or the hardware of the FLIR One.

To be honest, I don't understand your issue with the upscaling. While it's true that native resolution data is the most optimal, if we consider the issues with sharpness on the Lepton's lens (see the FLIR One G2 actual resolution thread) making the sensor only resolve details similarly to a ~120x90 sensor (even though the sensor really is 160x120) and the fact that the Lepton's temperature accuracy is ±2 degrees C, I doubt the upscaling makes any appreciable difference to the observed accuracy of the temperature readings.

Do you have the software programming skills needed to write a driver for me, that will let me use a FLIR One for Android as a webcam on my PC? If so, please write this driver for me. I have no interest in building a thermal webcam from scratch, by soldering together a project board like the one mentioned in an above post. It should ideally be a VFW (video for windows) driver, as I have recently discovered how to control webcams in Visual Basic 6, using VFW drivers.
 

Offline encryptededdy

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: nz
Re: Question about FLIR One for Android
« Reply #6 on: October 05, 2015, 06:48:06 am »
I literally just said that no soldering is required (at least for the previous boards they've shipped).

I don't have a skills to write a driver, and I also don't have access to the FLIR One gen 2 at this time.

I think your best bet is to wait until Groupgets release their USB interface board. I'm sure it will come with sample software that you can use.
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #7 on: October 06, 2015, 04:04:51 am »
I literally just said that no soldering is required (at least for the previous boards they've shipped).

I don't have a skills to write a driver, and I also don't have access to the FLIR One gen 2 at this time.

I think your best bet is to wait until Groupgets release their USB interface board. I'm sure it will come with sample software that you can use.

As far as I know, the only Lepton chip being sold as a separate component is the old one with 80x60 resolution. The new one with 160x120 resolution is not yet being sold to the public, and is only found inside gen-2 FLIR One units. Are you aware of any plans FLIR has to sell the new Lepton chip as a separate component?
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #8 on: October 06, 2015, 05:11:32 pm »
50 views and no replies? I think there was an entire thread, several pages long, regarding 3rd party drivers for the Seek Thermal imager. I'd think this would be a hot topic, but nobody has replied yet.

The only reason why there is no discussion, is the lack of a Flir One G2 camera.
In Germany no trader can deliver this part.
The combination of a thermal camera with an automatic shutter and a real camera is a nice feature for robotics, spy cams and another hacker toys.

You can download the Flir One SDK and study the interesting docs and the code sample.
There is a precompiled flir library for Arm7 CPU. This is the only part which needs reverse engineering  :)

Until now we only know the similar USB announcements from Flir and Seek cameras (iAP Interface)

see my post here
https://www.eevblog.com/forum/testgear/new-flir-products/msg750352/#msg750352
« Last Edit: October 06, 2015, 05:16:12 pm by tomas123 »
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #9 on: October 07, 2015, 03:11:03 am »
50 views and no replies? I think there was an entire thread, several pages long, regarding 3rd party drivers for the Seek Thermal imager. I'd think this would be a hot topic, but nobody has replied yet.

The only reason why there is no discussion, is the lack of a Flir One G2 camera.
In Germany no trader can deliver this part.
The combination of a thermal camera with an automatic shutter and a real camera is a nice feature for robotics, spy cams and another hacker toys.

You can download the Flir One SDK and study the interesting docs and the code sample.
There is a precompiled flir library for Arm7 CPU. This is the only part which needs reverse engineering  :)

Until now we only know the similar USB announcements from Flir and Seek cameras (iAP Interface)

see my post here
https://www.eevblog.com/forum/testgear/new-flir-products/msg750352/#msg750352

But there's lots of other discussion of FLIR products here, why not a lot about the FLIR One version2? I believe it can be sold in Germany too, by the way. It is only 9 frames per second, which means that it is not prevented from being sold outside the USA by ITAR. Besides, there's lots of people on these forums from many places in the world, including the USA.

If I buy one of these FLIR One for Android units for $250, I won't want to have to buy a separate chip (another $150) plus a project board in order to use it on a PC. I will want to use one unit (the one I spent $250 for) to be able to work on both the PC and android. So that's why I want to see some reverse engineering project going on regarding the FLIR One for Android.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #10 on: October 07, 2015, 10:12:53 am »
I believe it can be sold in Germany too, by the way.

Yes, it's shipped from Flir UK to Germany. But if I want a regular bill with germany VAT then I need a germany Flir distributor.
Flir moved the deliver date to the germany distributors from end of september to november.
« Last Edit: October 07, 2015, 10:15:26 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #11 on: October 07, 2015, 01:53:06 pm »
There is some RE going on, just not as obvious as in the early E4 and Seek days.

Attached is a annotated dump of the first few seconds of usb activity between a F1G2 and the F1 Android app.
It's not finished.
There may be inaccuracies.
There is much more to uncover.
This is a long way from a stand alone PC program.
Your mileage may vary.
blah, blah, blah.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #12 on: October 07, 2015, 10:43:06 pm »
very intersting  :-+
How do you got the datas from a android handy?
« Last Edit: October 07, 2015, 10:54:42 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #13 on: October 07, 2015, 10:47:17 pm »
I used my handy USB analyzer in series with the F1 and my tablet running F1 app.
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #14 on: October 07, 2015, 10:57:20 pm »
Guess I can't add a picture after the fact...

 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #15 on: October 07, 2015, 11:06:57 pm »
Thank you, but which nice hardware is this? (altium is a PCB design software)
« Last Edit: October 07, 2015, 11:09:25 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #16 on: October 07, 2015, 11:26:01 pm »
Sorry, forgot to add the link:

http://openvizsla.org/

Part of a KickStarter campaign, took many years to get the hardware, but it finally arrived, and works too!
Though it does take a bit of fiddling, and there is no nice GUI.

 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #17 on: October 08, 2015, 09:49:30 am »
really nice hardware :-+

as you posted here
https://www.eevblog.com/forum/testgear/new-flir-products/msg752703/#msg752703
it's possible to run the Flir Tools under Chrome with ARChon

I succesfull tested it!!
That's great, because the Flir Apps don't run under Android Studio because there is a precompiled library libflirsdk.so for armeabi-v7a.
There is is same problem with the Flir One SDK.

Unfortunately as yet I haven't a Flir One Android and can't test it: (I'm waiting for delivery).
It is possible to greb the USB traffic between camera and app (under Chrome+ARChon) with a "normal" windows usb sniffer (like sysinternals etc)?

 :palm: ARChon doesn't support the USB Port  :(

PS: https://developer.chrome.com/apps/getstarted_arc
Quote
PC, Mac, Linux, or Chromebook on Chrome Version 41+.

    Note: ARC is no longer supported on 32-bit x86 platforms and those platforms will no longer receive updates after October 13, 2015. All ARM platforms will continue to work and receive updates.
« Last Edit: October 08, 2015, 11:10:25 am by tomas123 »
 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #18 on: October 08, 2015, 12:26:05 pm »
I received my replacement F1G2 this week. From my conversations with Bill Terre, VP FLIR, it is apparent that demand has far outstripped supply of this little camera. FLIR were not expecting such initial demand for the unit. This is good news as it will hopefully lead to a healthy user base and community support.

It is obvious from FLIRs invitation to developers to create new apps that they wish to encourage product development in many areas. It would be worth registering as a developer on the FLIR ONE web site as this gives access to the SDK, developer documentation and the community forum.

I can foresee the development of applications that run on Windows, Linux, Android etc.If FLIR really want to 'own' this market segment they may be willing to provide developer information for cross platform use.

Bill Terre is VP, GM and OEM market development so an email to him may gain a useful response. Bill is a gentleman and he has been very friendly and helpful to me in recent communications. Great chap.

I have been looking at the cheap Android TV boxes this week to see if they would run the FLIR ONE app. They are really just an ARM based computer and many will run most Android apps with a keyboard and mouse. They have a suitable USB port so should work. The issue will be processor power. Most TV boxes use older ARMtechnology, such as ARM 5 or 7.not great for the FLIR ONE app.

For those unaware, the FLIR ONE Android app was developed on a Samsung S5 and FLIR expect users to use similar powerful hardware. The S5 runs its modern processor at 2.5 GHz.

IMHO, the F1G2 should be considered a very reasonably priced thermal imaging building block. I see no reason to limit its use to just phones and tablets running Android. With a ZnSe close up lens it would make a cheap PCB thermal profiling camera. It could be run on a micro USB cable from a desktop host.

I am hopeful that the F1G2 will become a ground breaking camera that is embraced by the maker community. FLIR will likely release the LEPTON 3  as a part once the demand for the F1G2 can be met.

In the mean time FLIR are looking at placing thermal camera technology into all manner of test products. I have seen the new clamp meter and expect to see a thermal camera equipped multimeter in the future. The LEPTON is so small that it may be incorporated into many devices. Thermal imaging for the masses is coming. The F1G2 could become the VW Beetle of thermal cameras.

Fraser
« Last Edit: October 08, 2015, 12:30:55 pm by Fraser »
 

Offline Balaur

  • Supporter
  • ****
  • Posts: 525
  • Country: fr
Re: Question about FLIR One for Android
« Reply #19 on: October 08, 2015, 03:47:01 pm »
Bummer, I've just received a mail from the eBay seller where I've ordered the Flir One. According to this message, FLIR announced that they had a huge (and unexpected?) success with this product and will not be able to meet the promised delivery times. (Apparently more than 2 million devices have been pre-ordered)

Shipments originally expected on Sep 30 have now a delay of 6 to 8 weeks and will be rationed (fairly?).
 

Online Bud

  • Super Contributor
  • ***
  • Posts: 4040
  • Country: ca
Re: Question about FLIR One for Android
« Reply #20 on: October 08, 2015, 04:19:36 pm »
And because of Flir's creepy practice to phone home (will this nice feature be embedded into the SDK?), it is a good time fo Flir to get a better "home" server to handle the increased volume of data.
Facebook-free life and Rigol-free shack.
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #21 on: October 08, 2015, 04:50:35 pm »
Fraser,

My F1G2 works well on the Hardkernel XU4,
at < $US100, with an octa core processor, it's quite snappy with the F1 app. Runs Android or one of several flavours of Linux.

I am a Flir Registered dev. and have their SDK. So far, only Android, and it is a bit fiddly to get working.
I have been able to build the sample app, and although they say it will run on Android 4.x, my 4.4.2 tablet refuses to load it.
My 5.1.1 tablet loads & runs it, but it crashes. I need to get adb over wifi working again so I can see what's going on.
I think that there are some files missing from the built .apk file, but I need some time to play with it some more.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #22 on: November 11, 2015, 05:01:54 pm »
There is some RE going on, just not as obvious as in the early E4 and Seek days.

Attached is a annotated dump of the first few seconds of usb activity between a F1G2 and the F1 Android app.
It's not finished.
There may be inaccuracies.
There is much more to uncover.
This is a long way from a stand alone PC program.
Your mileage may vary.
blah, blah, blah.

Hi cynfab,

you dumped the usb traffic.

I wrote here and in the following posts some nice details about the Flir One SDK app.
https://www.eevblog.com/forum/testgear/actual-resolution-of-flir-one-v2/msg797214/#msg797214

The SDK contain a compiled modul flironesdk.aar with a system library libjnidevicewrapper.so and a classes.jar
With classes.jar we get some interesting details about the USB protocol like the endpoint numbers.

Code: [Select]
package com.flir.flironesdk.usb;

import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbRequest;
import android.util.Log;
import java.io.Closeable;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;

public class UsbCommunicator
  implements Closeable
{
  private boolean IS_SIMULATED;
  private Delegate mDelegate;
  private volatile UsbDeviceConnection connection;
  private static final String LOG_TAG = "UsbCommunicator";
  private static final int SET_INTERFACE = 11;
  private static final int CTRL_TRANSFER_TIMEOUT = 200;
  static final int FRAME_READ_ENDPOINT_ID = 5;
  static final int CONFIG_READ_ENDPOINT_ID = 1;
  static final int CONFIG_WRITE_ENDPOINT_ID = 2;
  static final int FILEIO_READ_ENDPOINT_ID = 3;
  static final int FILEIO_WRITE_ENDPOINT_ID = 4;
  static final int SUPPORTED_VENDOR_ID = 2507;
  static final int SUPPORTED_PRODUCT_ID = 6550;
  private UsbEndpoint configWriteEndpoint;
 
  public static abstract interface Delegate
  {
    public abstract void onDataReceived(byte[] paramArrayOfByte, UsbCommunicator.ProtocolType paramProtocolType);
   
    public abstract void onCommunicationAvailabilityChange(boolean paramBoolean);
  }
 
  public static enum ProtocolType
  {
    CONFIGURATION((byte)1),  FILEIO((byte)2),  FRAME((byte)4);
   
    private final byte value;
   
    private ProtocolType(byte value)
    {
      this.value = value;
    }
   
    byte getValue()
    {
      return this.value;
    }
  }
 
  private UsbEndpoint fileioWriteEndpoint = null;
  final UsbRequest frameReadRequest = new UsbRequest();
  final UsbRequest fileioReadRequest = new UsbRequest();
  final UsbRequest configReadRequest = new UsbRequest();
  private UsbDevice mDevice;
  volatile boolean connected = false;
  volatile boolean expectFrameData = false;
  volatile boolean expectFileData = false;
 
  public static boolean deviceIsValid(UsbDevice device)
  {
    try
    {
      validateDevice(device);
      return true;
    }
    catch (Exception e)
    {
      Log.e("UsbCommunicator", "Invalid device: " + e.getMessage());
    }
    return false;
  }
 
  public static void validateDevice(UsbDevice device)
    throws Exception
  {
    if (device.getVendorId() != 2507) {
      throw new Exception("Unsupported USB Vendor ID of " + Integer.toHexString(device.getVendorId()));
    }
    if (device.getProductId() != 6550) {
      throw new Exception("Unsupported USB Product ID of " + Integer.toHexString(device.getProductId()));
    }
    int ifaceCount = device.getInterfaceCount();
    HashMap<Integer, Boolean> inEndpointsFound = new HashMap();
    HashMap<Integer, Boolean> outEndpointsFound = new HashMap();
    inEndpointsFound.put(Integer.valueOf(3), Boolean.valueOf(false));
    inEndpointsFound.put(Integer.valueOf(1), Boolean.valueOf(false));
    inEndpointsFound.put(Integer.valueOf(5), Boolean.valueOf(false));
    outEndpointsFound.put(Integer.valueOf(2), Boolean.valueOf(false));
    outEndpointsFound.put(Integer.valueOf(4), Boolean.valueOf(false));
    UsbInterface iface;
    for (int i = 0; i < ifaceCount; i++)
    {
      iface = device.getInterface(i);
     
      int endpointCount = iface.getEndpointCount();
      for (int e = 0; e < endpointCount; e++)
      {
        UsbEndpoint ep = iface.getEndpoint(e);
        if (ep.getDirection() == 128) {
          inEndpointsFound.put(Integer.valueOf(ep.getEndpointNumber()), Boolean.valueOf(true));
        } else {
          outEndpointsFound.put(Integer.valueOf(ep.getEndpointNumber()), Boolean.valueOf(true));
        }
      }
    }
    HashSet<Map.Entry<Integer, Boolean>> allEndpointsFound = new HashSet();
    allEndpointsFound.addAll(inEndpointsFound.entrySet());
    allEndpointsFound.addAll(outEndpointsFound.entrySet());
    for (Map.Entry<Integer, Boolean> endpoint : allEndpointsFound) {
      if (!((Boolean)endpoint.getValue()).booleanValue()) {
        throw new Exception("Unable to communicate with USB device, endpoint " + ((Integer)endpoint.getKey()).toString() + " not found");
      }
    }
  }
 
  public UsbCommunicator(UsbDevice device, UsbDeviceConnection usbConnection, Delegate delegate)
    throws Exception
  {
    validateDevice(device);
   
    this.mDelegate = delegate;
    this.connection = usbConnection;
    this.mDevice = device;
   
    int ifaceCount = device.getInterfaceCount();
    for (int i = 0; i < ifaceCount; i++)
    {
      UsbInterface iface = device.getInterface(i);
      if (false == this.connection.claimInterface(iface, false))
      {
        Log.e("UsbCommunicator", "Unable to claim interface " + iface.getId() + ", close connection and try again.");
        delegate.onCommunicationAvailabilityChange(false);
        throw new Exception("Unable to claim USB interface");
      }
      int endpointCount = iface.getEndpointCount();
      for (int e = 0; e < endpointCount; e++)
      {
        UsbEndpoint ep = iface.getEndpoint(e);
        if (ep.getDirection() == 128) {
          switch (ep.getEndpointNumber())
          {
          case 5:
            this.frameReadRequest.initialize(this.connection, ep);
            break;
          case 1:
            this.configReadRequest.initialize(this.connection, ep);
            break;
          case 3:
            this.fileioReadRequest.initialize(this.connection, ep);
            break;
          case 2:
          case 4:
          default:
            Log.w("UsbCommunicator", "Unknown USB_DIR_IN Endpoint on device!");break;
          }
        } else {
          switch (ep.getEndpointNumber())
          {
          case 2:
            this.configWriteEndpoint = ep;
            break;
          case 4:
            this.fileioWriteEndpoint = ep;
            break;
          default:
            Log.w("UsbCommunicator", "Unknown USB_DIR_OUT Endpoint on device!");
          }
        }
      }
    }
    if (this.fileioWriteEndpoint != null)
    {
      stopCommunication(ProtocolType.FRAME);
      stopCommunication(ProtocolType.FILEIO);
    }
    else
    {
      delegate.onCommunicationAvailabilityChange(false);
    }
  }
 
  final int CONFIG_BUFFER_SIZE = 4096;
  final int FRAME_BUFFER_SIZE = 131072;
  final int FILE_BUFFER_SIZE = 1048576;
  final ByteBuffer configBuffer = ByteBuffer.allocate(4096);
  final ByteBuffer frameBuffer = ByteBuffer.allocate(131072);
  final ByteBuffer fileBuffer = ByteBuffer.allocate(1048576);
 
  private void pollEndpoints()
  {
    new Thread(new Runnable()
    {
      public void run()
      {
        Log.d("configReadRequest", "Starting configReadRequest poll loop...");
        UsbCommunicator.this.configReadRequest.queue(UsbCommunicator.this.configBuffer, 4096);
        while (UsbCommunicator.this.connected)
        {
          UsbRequest requestResult = UsbCommunicator.this.connection.requestWait();
          synchronized (UsbCommunicator.this.configReadRequest)
          {
            if (!UsbCommunicator.this.connected) {
              break;
            }
            if (requestResult == UsbCommunicator.this.configReadRequest)
            {
              byte[] data = new byte[UsbCommunicator.this.configBuffer.position()];
              UsbCommunicator.this.configBuffer.flip();
              UsbCommunicator.this.configBuffer.get(data);
              if (data.length > 0) {
                UsbCommunicator.this.mDelegate.onDataReceived(data, UsbCommunicator.ProtocolType.CONFIGURATION);
              }
              UsbCommunicator.this.configBuffer.clear();
              UsbCommunicator.this.configReadRequest.queue(UsbCommunicator.this.configBuffer, 4096);
            }
            else if (requestResult == UsbCommunicator.this.frameReadRequest)
            {
              byte[] data = new byte[UsbCommunicator.this.frameBuffer.position()];
              UsbCommunicator.this.frameBuffer.flip();
              UsbCommunicator.this.frameBuffer.get(data);
              if (data.length > 0) {
                UsbCommunicator.this.mDelegate.onDataReceived(data, UsbCommunicator.ProtocolType.FRAME);
              }
              if (UsbCommunicator.this.expectFrameData) {
                UsbCommunicator.this.frameReadRequest.queue(UsbCommunicator.this.frameBuffer, 131072);
              }
              UsbCommunicator.this.frameBuffer.clear();
            }
            else if (requestResult == UsbCommunicator.this.fileioReadRequest)
            {
              byte[] data = new byte[UsbCommunicator.this.fileBuffer.position()];
              UsbCommunicator.this.fileBuffer.flip();
              UsbCommunicator.this.fileBuffer.get(data);
              UsbCommunicator.this.mDelegate.onDataReceived(data, UsbCommunicator.ProtocolType.FILEIO);
              UsbCommunicator.this.fileBuffer.clear();
              if (UsbCommunicator.this.expectFileData) {
                UsbCommunicator.this.fileioReadRequest.queue(UsbCommunicator.this.fileBuffer, 1048576);
              }
            }
          }
        }
      }
    })
   
      .start();
  }
 
  public UsbCommunicator(Delegate usbDelegate)
  {
    Log.i("UsbCommunicator", "Simulated device constructor");
    this.mDelegate = usbDelegate;
    this.IS_SIMULATED = true;
  }
 
  private void sendData(UsbEndpoint ep, byte[] data, int length)
  {
    Log.d("UsbCommunicator", "Sending " + length + " bytes on EP" + ep.getEndpointNumber());
    synchronized (this.connection)
    {
      int offset = 0;
      while (offset < length)
      {
        int result = this.connection.bulkTransfer(ep, data, offset, length - offset, 500);
        if (result > 0)
        {
          Log.d("UsbCommunicator", "Bulk transfer sent " + result + " bytes on Endpoint " + ep.getEndpointNumber());
          offset += result;
        }
        else
        {
          Log.w("UsbCommunicator", "Bulk Transfer Failed on Endpoint " + ep.getEndpointNumber());
        }
      }
    }
  }
 
  native void sendConfigDataToSimulatedDevice(byte[] paramArrayOfByte);
 
  public void sendDataToDevice(byte[] data, ProtocolType protocolType)
  {
    if (this.IS_SIMULATED)
    {
      switch (protocolType)
      {
      case CONFIGURATION:
        sendConfigDataToSimulatedDevice(data);
        break;
      }
    }
    else
    {
      UsbEndpoint destinationEndpoint;
      UsbEndpoint destinationEndpoint;
      switch (protocolType)
      {
      case CONFIGURATION:
        destinationEndpoint = this.configWriteEndpoint;
        break;
      case FILEIO:
        destinationEndpoint = this.fileioWriteEndpoint;
        break;
      default:
        Log.w("UsbCommunicator", "Attempted to send data on knosupported protocol!"); return;
      }
      UsbEndpoint destinationEndpoint;
      sendData(destinationEndpoint, data, data.length);
    }
  }
 
  public void sendConfigData(byte[] data)
  {
    sendDataToDevice(data, ProtocolType.CONFIGURATION);
  }
 
  public void sendFileioData(byte[] data)
  {
    sendDataToDevice(data, ProtocolType.FILEIO);
  }
 
  public void close()
  {
    if (this.connected)
    {
      pause();
     
      this.connection.close();
      this.mDelegate.onCommunicationAvailabilityChange(false);
      Log.d("UsbCommunicator", "Connection closed.");
    }
  }
 
  public void pause()
  {
    if (this.connected)
    {
      synchronized (this.configReadRequest)
      {
        stopFrames();
        stopCommunication(ProtocolType.FILEIO);
        this.connected = false;
        this.configReadRequest.cancel();
        this.configBuffer.clear();
       
        this.fileioReadRequest.cancel();
       
        this.frameReadRequest.cancel();
      }
      this.mDelegate.onCommunicationAvailabilityChange(false);
    }
  }
 
  private void startFrames()
  {
    startCommunication(ProtocolType.FRAME);
  }
 
  private void stopFrames()
  {
    stopCommunication(ProtocolType.FRAME);
  }
 
  private void startCommunication(ProtocolType protocolType)
  {
    toggleCommunication(protocolType, true);
  }
 
  private void stopCommunication(ProtocolType protocolType)
  {
    toggleCommunication(protocolType, false);
  }
 
  private void toggleCommunication(ProtocolType protocolType, boolean startCommunication)
  {
    if (this.IS_SIMULATED == true) {
      return;
    }
    switch (protocolType)
    {
    case FRAME:
      int interfaceNumber = 2;
      this.expectFrameData = startCommunication;
      this.frameBuffer.clear();
      if (this.expectFrameData) {
        this.frameReadRequest.queue(this.frameBuffer, 131072);
      }
      break;
    case FILEIO:
      int interfaceNumber = 1;
      this.expectFileData = startCommunication;
      this.fileBuffer.clear();
      if (this.expectFileData) {
        this.fileioReadRequest.queue(this.fileBuffer, 1048576);
      }
      break;
    case CONFIGURATION:
      Log.w("UsbCommunicator", "Configuration Protocol cannot be started or stopped.");
    default:
      return;
    }
    int interfaceNumber;
    int altSetting = startCommunication ? 1 : 0;
    synchronized (this.connection)
    {
      int result = this.connection.controlTransfer(1, 11, altSetting, interfaceNumber, null, 0, 200);
      Log.d("UsbCommunicator", "Result from control transfer: " + result);
    }
  }
 
  public void connect()
  {
    if (!this.connected)
    {
      this.connected = true;
      this.mDelegate.onCommunicationAvailabilityChange(true);
      startCommunication(ProtocolType.FILEIO);
      pollEndpoints();
    }
  }
}
« Last Edit: November 11, 2015, 05:04:31 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #23 on: November 11, 2015, 06:05:33 pm »
Thanks for that,
I've been tied up with other projects,
I was able to recompile the example app from the sdk, but it just crashed on the 2 tablets I use for the Flir ONE, I was a bit disappointed, till you posted about the cropping issues. So I tried your recompilation, and found it did the same thing. I then tried it on my Odroid XU4, and it works just fine!. So I believe that there is a performance issue with the Example App and if your phone/tablet doesn't have the horsepower it just crashes.

I'll take a look at what you just posted as soon as I cand find some time.


   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #24 on: November 12, 2015, 09:23:33 pm »
So I believe that there is a performance issue with the Example App and if your phone/tablet doesn't have the horsepower it just crashes.

I compiled also against the old SDK 1.0.1 ( FLIROneSDK-Android-1_0_1.zip )

there is  newer version
Quote
SDK 1.0.2

CHANGE LOG

Improves reliability of saving and loading frames.


The file size of system library  libjnidevicewrapper.so is shrinked from 33MB to 16MB  :-+

try it
« Last Edit: November 12, 2015, 09:26:43 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #25 on: November 13, 2015, 01:21:25 pm »
I was able to recompile the example app from the sdk

I think you are the only one, who testing the Flir SDK.
Here you can download a working SDK sample with the extracted java.class (see my post above)
 see path FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir\flironesdk\usb

have fun
http://www.file-upload.net/download-11040066/FLIROneSDKBundle04-Basis.zip.html
« Last Edit: November 13, 2015, 01:38:16 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #26 on: November 18, 2015, 12:39:38 pm »
Attached is a annotated dump of the first few seconds of usb activity between a F1G2 and the F1 Android app.

Hi cynfab,

with knowledge of "FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir\flironesdk\usb\UsbCommunicator.java" I'm played around with your nice usb dump file F6c.txt and found some interesting strings in your hex bytes:
Code: [Select]
>awk "{for(i=1; i <=NF; i=i+1) {tmp=sprintf (\"%s \",\"0x\"$(i)); printf \"%c\", strtonum(tmp) }}" F6c.txt > strings.txt

>strings -n 7 strings.txt
Sysinternals - [url=http://www.sysinternals.com]www.sysinternals.com[/url]

FLIR ONE Camera
FLIR Systems
FLIRONEF0XXX200
SBIBDP Configuration
iAP Interface
com.flir.rosebud.fileio
com.flir.rosebud.frame
{"type":"sledInformation","data":{"serialNumberBoard":"F03XXX00571","partNumberBoard":"21200160201","versionBoard":"C","serialNumberLepton":"355692","versionLepton":"3.1.45","leptonQR":"A0355692","versionRosebudFactoryESW":"0.4.25","versionRosebudOperationalESW":"0.4.26","versionRosebudUpdaterESW":"0.4.26","versionRosebudAPI":"master.26498f5","gitRevision":"master.26498f5","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatinwp
gMode":"operational"}}
{"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
{"type":"readFile","data":{"streamIdentifier":10}}
/CameraFiles/system/calib.rsc
/CameraFiles/system/maps/ds_we_ap_fi_le_LCFMap.fff
/CameraFiles/system/maps/ds_we_ap_fi_leExFOL2_LCFMap.fff
/CameraFiles/system/calib.rscPK
/CameraFiles/system/maps/ds_we_ap_fi_le_LCFMap.fffPK
/CameraFiles/system/maps/ds_we_ap_fi_leExFOL2_LCFMap.fffPK
{"type":"readFile","data":{"streamIdentifier":10}}
{"type":"setOption","data":{"option":"autoFFC","value":true}}
{"type":"setOptionStatus","data":{"option":"autoFFC","value":-1}}

Unfortunately your dump stops from that moment where the interesting parts begins:
The see some configurations of the F1 device (configWriteEndpoint) and the begin of the streaming of frames (frameReadRequest) it has not started yet :(

Code: [Select]

FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir\flironesdk\usb\UsbCommunicator.java
...
            for ( int e = 0 ; e < endpointCount; e++)
            {
                UsbEndpoint ep = iface.getEndpoint(e);
                if (ep.getDirection() == 128) {          // read
                    switch (ep.getEndpointNumber())
                    {
                        case 5:               // FRAME_READ_ENDPOINT_ID
                            this.frameReadRequest .initialize(this. connection, ep);
                            break;
                        case 1:
                            this.configReadRequest .initialize(this. connection, ep);
                            break;
                        case 3:
                            this.fileioReadRequest .initialize(this. connection, ep);   // final UsbRequest fileioReadRequest = new UsbRequest();
                            break;
                        case 2:
                        case 4:
                        default:
                            Log. w("UsbCommunicator", "Unknown USB_DIR_IN Endpoint on device!");break;
                    }
                } else {                                  // write
                    switch (ep.getEndpointNumber())       
                    {
                        case 2:
                            this.configWriteEndpoint = ep;
                            break;
                        case 4:
                            this.fileioWriteEndpoint = ep;
                            break;
                        default:
                            Log. w("UsbCommunicator", "Unknown USB_DIR_OUT Endpoint on device!");
                    }
                }



Furthermore I have only bad USB programmer skills.

I can't find this known Read/Write Endpoint Addresses in your dump:
edit: found it
Code: [Select]
Call to address 78 endpoint 1:
[        ]   3.233349 d=  0.000001 [191.7 + 12.633] [  3] IN   : 78.1 

list of Endpoint Addresses
Code: [Select]
# lsusb -v -d 09cb:1996 | grep bEndpointAddress
      iInterface              5 iAP Interface
        bEndpointAddress     0x81  EP 1 IN
        bEndpointAddress     0x02  EP 2 OUT

      iInterface              6 com.flir.rosebud.fileio
        bEndpointAddress     0x83  EP 3 IN
        bEndpointAddress     0x04  EP 4 OUT

      iInterface              7 com.flir.rosebud.frame
        bEndpointAddress     0x85  EP 5 IN
        bEndpointAddress     0x06  EP 6 OUT

compared lsusb with UsbCommunicator.java I understand the relations between EndpointNumbers and InterfaceNumbers:
Code: [Select]
    static final int CONFIG_READ_ENDPOINT_ID = 1 ;
    static final int CONFIG_WRITE_ENDPOINT_ID = 2 ;
    static final int FILEIO_READ_ENDPOINT_ID = 3 ;
    static final int FILEIO_WRITE_ENDPOINT_ID = 4 ;
    static final int FRAME_READ_ENDPOINT_ID = 5 ;

Can you please give us some more output from your nice protocoll sniffer to see the full handshake until the stream begin? FRAME_READ_ENDPOINT_ID = 5 ;)
You debug snippet only grep EndPoint 1,2 (configuration) and 3 (file transfer of CameraFiles.zip, see magic bytes "PK"):
Code: [Select]
>grep ": 78\." F6c.txt
IN   : 78.0
IN   : 78.1
OUT  : 78.2
IN   : 78.3
« Last Edit: November 18, 2015, 03:27:38 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #27 on: November 18, 2015, 03:19:18 pm »
thomas123,

Sorry I haven't kept you up to date on my disassembly of the usb stream. It is sort of on the back burner while I'm fiddling with the SDK.
Reading the SDK decompiled code is very interesting too, and I hope to tie it and the usb dump together someday.
But until then, here is a somewhat more annotated version of the dump.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #28 on: November 18, 2015, 10:17:41 pm »
great, a complete handshake until transfer of first raw image

Code: [Select]
$ gawk  -bniord  '{for(i=1; i <=NF; i=i+1) {tmp=sprintf ("%s ","0x"$(i)); printf "%c", strtonum(tmp)}}' F6d.txt | strings -n 7

{"type":"sledInformation","data":{"serialNumberBoard":"F03xxx00571","partNumberBoard":"21200160201","versionBoard":"C","serialNumberLepton":"355692","versionLepton":"3.1.45","leptonQR":"A0355692","versionRosebudFactoryESW":"0.4.25","versionRosebudOperationalESW":"0.4.26","versionRosebudUpdaterESW":"0.4.26","versionRosebudAPI":"master.26498f5","gitRevision":"master.26498f5","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatinwp
gMode":"operational"}}
{"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
{"type":"readFile","data":{"streamIdentifier":10}}
// comment: strings inside CameraFiles.zip:
     /CameraFiles/system/calib.rsc
     /CameraFiles/system/maps/ds_we_ap_fi_le_LCFMap.fff
     /CameraFiles/system/maps/ds_we_ap_fi_leExFOL2_LCFMap.fff
     /CameraFiles/system/calib.rscPK
     /CameraFiles/system/maps/ds_we_ap_fi_le_LCFMap.fffPK
     /CameraFiles/system/maps/ds_we_ap_fi_leExFOL2_LCFMap.fffPK
{"type":"readFile","data":{"streamIdentifier":10}}
{"type":"setOption","data":{"option":"autoFFC","value":true}}
{"type":"setOptionStatus","data":{"option":"autoFFC","value":-1}}
{"type":"setOption","data":{"option":"autoFFC","value":true}}
{"type":"setOptionStatus","data":{"option":"autoFFC","value":true}}

now comes the first raw frame on endpoint 5
Code: [Select]
[        ]  21.637696 d=  0.000001 [ 12.5 +  2.967] [  3] IN   : 89.5
[        ]  21.637697 d=  0.000000 [ 12.5 +  3.467] [515] DATA0: ef be 00 00 01 00 00 00 19 25 02 00 ac 9b 00 00 c8 88 01 00 a5 00 00 00 16 bb 99 10 00 50 7e 7c 9f 09 98 09 b7 09 c8 09 c6 09 c5 09 d4 09 d6 09 de 09 ee 09 ee 09 ff 09 02 0a 09 0a 1b 0a 0a 0a 1f 0a 29 0a 22 0a 29 0a 29 0a 33 0a 2b 0a 39 0a 2f 0a 40 0a 37 0a 40 0a 53 0a 48 0a 47 0a 49 0a 57 0a 53 0a 55 0a 5c 0a 57 0a 5c 0a 5e 0a 6e 0a 6a 0a 6d 0a 67 0a 71 0a 73 0a 67 0a 6f 0a 6d 0a 76 0a 72 0a 6c 0a 77 0a 76 0a 7c 0a 77 0a 77 0a 7a 0a 76 0a 77 0a 7e 0a 82 0a 7e 0a 8d 0a 88 0a 8d 0a 8e 0a 85 0a 7c 0a 8f 0a 8f 0a 8b 0a 82 0a 85 0a 8c 0a 8d 0a 93 0a 8c 0a 7c 0a 8e 0a 91 0a 01 00 a6 66 94 0a 8b 0a 8e 0a 95 0a 8c 0a 93 0a 8b 0a 9a 0a 91 0a 8c 0a 89 0a 8f 0a 8b 0a 8e 0a 99 0a 8b 0a 8b 0a 8a 0a 84 0a 90 0a 82 0a 8b 0a 82 0a 83 0a 83 0a 81 0a 85 0a 75 0a 80 0a 76 0a 73 0a 83 0a 74 0a 81 0a 7d 0a 72 0a 6a 0a 65 0a 75 0a 6c 0a 63 0a 71 0a 67 0a 61 0a 65 0a 5f 0a 61 0a 60 0a 5d 0a 55 0a 55 0a 56 0a 48 0a 46 0a 3f 0a 36 0a 41 0a 42 0a 27 0a 2d 0a 22 0a 2c 0a 31 0a 25 0a 1c 0a 27 0a 18 0a 1c 0a 1a 0a 17 0a 14 0a 06 0a fc 09 f8 09 0b 0a f2 09 eb 09 e7 09 dc 09 d6 09 02 00 f8 6c b2 09 c1 09 cc 09 d0 09 cd 09 da 09 e3 09 f2 09 f1 09 03 0a 04 0a 0b 0a 09 0a 17 0a 23 0a 1a 0a 30 0a 38 0a 37 0a 38 0a 35 0a 43 0a 39 0a 43 0a 41 0a 4b 0a 4c 0a 46 0a 50 0a 4c 0a 56 0a 57 0a 59 0a 6c 0a 6f 0a 5d 0a 6b 0a 66 0a 6a 0a 71 0a 71 0a 77 0a 7d 0a 7f 0a 77 0a 7b 0a 7b 0a 79 0a 82 0a 86 0a 80 0a 7a 0a 7d 0a 88 0a 7e 0a 7f 0a 84 0a 86 0a 89 0a 84 0a 8c 0a 87 0a 87 0a 96 0a 96 0a 95 0a 8c 0a 99 0a 8a 0a 9b 0a 8f 0a 8c 0a 96 0a 92 0a 88 0a 9f 0a 8e a2

515 Bytes are short, but it looks that the lines are 164 (160+4) Byte long, as described here (after a header ef be 00 00 01 00 00 00... ):

« Last Edit: November 18, 2015, 10:54:33 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #29 on: November 19, 2015, 10:10:34 am »
a note about the crop factor

the start process of "regular" Flir One App  (from play store):
(1) copy the simulator config file CameraFiles.zip to folder \Android\data\com.flir.flirone\files\
(2) decompress it to folder \Android\data\com.flir.flirone\files\CameraFiles
(3) try to open the USB Flir One
(4) copy from Flir One Device his CameraFiles.zip to  \Android\data\com.flir.flirone\files\
(5) decompress it to folder \Android\data\com.flir.flirone\files\CameraFiles

With step (5) the simulator config file .\CameraFiles\system\calib.rsc with "uncropped full resolution" is changed with calib.rsc from Flir One with magnQuote>1.
The crop factor switch in calib.rsc of simulator device:
Code: [Select]
     .calib.visual.fusion.leExFOL2.magnQuote double 0
     .calib.visual.fusion.leExFOL2.magnQuoteComp double 0

The crop factor switch in calib.rsc of real Flir One device:
Code: [Select]
     .calib.visual.fusion.leExFOL2.magnQuote double 1.2312108
     .calib.visual.fusion.leExFOL2.magnQuoteComp double 0

 160/1.2312108=130,0  >:D


« Last Edit: November 19, 2015, 11:43:52 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #30 on: November 19, 2015, 08:29:31 pm »
It is sort of on the back burner while I'm fiddling with the SDK.

the simplest way to defeat the crop factor is comment out the line 213 in
flironesdk/Device.java
Code: [Select]
     //FrameProcessor.updateCameraFiles(zis, cachedContext.getFilesDir().getAbsolutePath() + File.separator);
now the sdk used the CameraFiles (extracted default_camera_files.zip) from simulator with magnQuote=0  ;)

The next step is to edit the calib.rsc in the CameraFiles.zip from your real FlirOne and replace it in the SDK file system with default_camera_files.zip.
Code: [Select]
./app/src/main/res/raw/default_camera_files.zip
Don't forget to edit the crc32 (see E4 thread)



As I wrote here
https://www.eevblog.com/forum/testgear/question-about-flir-one-for-android/msg803459/#msg803459
the Flir One App from play store stored your CameraFiles.zip in the public path Environment.getDataDirectory()
Code: [Select]
\Android\data\com.flir.flirone\files\CameraFilesHere you can grep the file >:D

Unfortunately the SDK stores the file to getFilesDir()
Code: [Select]
/data/data/com.flir.flironeexampleapplication/files/CameraFilesYou need a rootet device to read this path

see
http://stackoverflow.com/questions/21230629/getfilesdir-vs-environment-getdatadirectory
Quote
If you want to get your application path use getFilesDir() which will give you path /data/data/your package/files

You can get the path using the Environment var of your data/package using the getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath();
which will return the path from the root directory of your external storage as
/storage/sdcard/Android/data/your pacakge/files/data
« Last Edit: November 19, 2015, 09:07:02 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #31 on: November 19, 2015, 09:57:02 pm »
But you could also change the storage path code in FrameProcessor.java

Code: [Select]
    private FrameProcessor(Context context)
    {
        this.emissivity = EMISSIVITY_SKIN;  // was DEFAULT ie.0.95F km

        String storagePath = context.getFilesDir().getAbsolutePath() + File.separator;
        cameraFilesPath = storagePath + "CameraFiles";
        Boolean cameraFilesExists = Boolean.valueOf(new File(cameraFilesPath).exists());

        InputStream defaultCameraFilesInput = context.getApplicationContext().getResources().openRawResource(R.raw.default_camera_files);

        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(defaultCameraFilesInput));
        updateCameraFiles(zis, storagePath);

        setupAppCore(cameraFilesPath);
    }

So that it wasn't stored in a root protected path.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #32 on: November 20, 2015, 12:42:36 am »
of course  :)

a note:
the crop factor inside calib.rsc is not the suspected ".calib.visual.fusion.leExFOL2.magnQuote double 1.2312108"   :(

you find it in calib.rsc around the maps files entries
Code: [Select]
.calib.lensCorr entry
.calib.lensCorr.ds_we_ap_fi_le index
.calib.lensCorr.ds_we_ap_fi_le.enabled bool true
.calib.lensCorr.ds_we_ap_fi_le.fileName text "ds_we_ap_fi_le_LCFMap.fff"
.calib.lensCorr.ds_we_ap_fi_le.rotation double 0.32686445
.calib.lensCorr.ds_we_ap_fi_le.type int32 100
.calib.lensCorr.ds_we_ap_fi_le.zoom double 7.7799269
.calib.lensCorr.ds_we_ap_fi_leExFOL2 index
.calib.lensCorr.ds_we_ap_fi_leExFOL2.enabled bool true
.calib.lensCorr.ds_we_ap_fi_leExFOL2.fileName text "ds_we_ap_fi_leExFOL2_LCFMap.fff"
.calib.lensCorr.ds_we_ap_fi_leExFOL2.rotation double 0.32686445
.calib.lensCorr.ds_we_ap_fi_leExFOL2.type int32 100
.calib.lensCorr.ds_we_ap_fi_leExFOL2.zoom double 7.7799269
if I remove this block, then I have uncropped Lepton images with calibrated temperature measurements.
This is not the best solution. I'm unsure about the content of the both mapping files *.fff

After editing the calib.rsc you must calculate a new crc32.
I use this fast method:
Code: [Select]
// count (n) lines
$ wc -l calib.rsc
     646 calib.rsc

//print last line
$ tail -n1 calib.rsc
# CRC32 4683a151

//calc a new crc32 for (n-1) lines
$ crc32 <(head -n 645 calib.rsc)
4683a151

// edit last line
first test it on a unpatched sample and compare last line with output of crc32

After editing the calib.rsc inside
Code: [Select]
./app/src/main/res/raw/default_camera_files.zipwith my patched calib.rsc from my Flir One the SDK.app works fine.
Now I'm looking for an switch to suppress the magic pattern noise.
« Last Edit: November 20, 2015, 01:08:26 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #33 on: November 20, 2015, 01:03:37 am »
another idea hasen't work:

you can multiple ImageTypes request in same time

sample:
Code: [Select]
frameProcessor.setImageTypes(EnumSet.of(RenderedImage.ImageType.BlendedMSXRGBA8888Image, RenderedImage.ImageType.ThermalLinearFlux14BitImage));
from help
Quote
Called when a frame has been received and processed. Note: if you have requested N formats, this method will be called N times per Frame passed to the FrameProcessor instance. If your goal is to record a video from a sequence of frames, use android.media.MediaCodec and call mediaCodec.queueInputBuffer from this method with the frame's pixelData byte array put in the input ByteBuffer of the mediaCodec


I thought, if this.pixeldata from format ThermalLinearFlux14BitImage, then it's simple to copy it to this.rawFrame before I take a photo.

FLIROneSDKBundle/FLIRONEExampleApplication/app/src/main/java/com/flir/flironesdk/RenderedImage.java
Code: [Select]
    private RenderedImage(int width, int height, byte[] pixelData, byte frameTypeValue, float emissivity, int paletteOrdinal, Frame originalFrame)
    {
        this.width = width;
        this.height = height;
        this.pixelData = pixelData;
        this.imageType = ImageType.get(frameTypeValue);
        this.emissivity = emissivity;
        if ((paletteOrdinal >= 0) && (paletteOrdinal < Palette.values().length)) {
            this.palette = Palette.values()[paletteOrdinal];
        } else {
            this.palette = null;
        }
        this.rawFrame = originalFrame;
    }
But I haven't found a way to write to "private" array this.rawFrame.

 :(
« Last Edit: November 20, 2015, 01:10:35 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #34 on: November 20, 2015, 01:05:33 am »
Another quick n' dirty solution works fine:

Save the ThermalLinearFlux14BitImage RAW image:

FLIRONEExampleApplication/app/src/main/java/com/flir/flironeexampleapplication/PreviewActivity.java
Code: [Select]

// for raw images
import java.io.FileOutputStream;

   public void onFrameProcessed(final RenderedImage renderedImage){
        thermalBitmap = renderedImage.getBitmap();
        updateThermalImageView(thermalBitmap);


        /*
        Capture this image if requested.
        */
        if (this.imageCaptureRequested) {
            imageCaptureRequested = false;
            final Context context = this;
            new Thread(new Runnable() {
                public void run() {
                    String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ssZ", Locale.getDefault());
                    String formatedDate = sdf.format(new Date());
                    String fileName = "FLIROne-" + formatedDate + ".jpg";
                    try{
                        lastSavedPath = path+ "/" + fileName;
                        renderedImage.getFrame().save(new File(lastSavedPath), RenderedImage.Palette.Iron, RenderedImage.ImageType.BlendedMSXRGBA8888Image);

                        MediaScannerConnection.scanFile(context,
                                new String[]{path + "/" + fileName}, null,
                                new MediaScannerConnection.OnScanCompletedListener() {
                                    @Override
                                    public void onScanCompleted(String path, Uri uri) {
                                        Log.i("ExternalStorage", "Scanned " + path + ":");
                                        Log.i("ExternalStorage", "-> uri=" + uri);
                                    }

                                });
                        if (renderedImage.imageType() == RenderedImage.ImageType.ThermalLinearFlux14BitImage){
                            // save the Lepton RAW file
                            String rawName = "FLIROne-" + formatedDate + ".raw";
                            lastSavedPath = path+ "/" + rawName;
                            File file = new File(lastSavedPath);
                            FileOutputStream fop = null;
                            fop = new FileOutputStream(file);
                            if (!file.exists()) {
                                file.createNewFile();
                            }
                            //int rawLength = renderedImage.pixelData().length;
                            byte[] LeptonRAWBytes = renderedImage.pixelData();
                            fop.write(LeptonRAWBytes);
                            fop.flush();
                            fop.close();
                        }

                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            thermalImageView.animate().setDuration(50).scaleY(0).withEndAction((new Runnable() {
                                public void run() {
                                    thermalImageView.animate().setDuration(50).scaleY(1);
                                }
                            }));
                        }
                    });
                }
            }).start();
        }
...


If the image type is set to "ThermalLinearFlux14BitImage" then it save also the raw frame 160x120 to disk.

So I got the nice gallery photo from F1G2:
I wrote here something about the new Flir One G2 with Lepton 160x120.
https://www.eevblog.com/forum/testgear/flir-one-thermal-imaging-camera-teardown-and-hacks/msg801504/#msg801504

I shot comparison photos with Flir One G1, Flir One G2 , Flir E4 and Flir E40 from a motherboard.
The temperature scale is auto-level, but Flir tools use a different "gamma correction" for the color scale of E40.

Flir One G1 Lepton 80x60


Flir One G2 Lepton 160x120 Mode: ThermalLinearFlux14BitImage



Flir Ex 320x240



Flir Exx 320x240

« Last Edit: December 13, 2015, 11:35:24 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #35 on: November 20, 2015, 01:21:52 am »
I've been able to use the multiple image format FrameProcess request and indeed the onFrameProcessed delegate is call for each type, BUT there is no way for the delegate to determine what type of image it is UNLESS you modify Renderimage.java to make ImageType public

    public ImageType imageType; 

I have an app that displays the 14bit thermal greyscale image and the visual image simultaneously in separate ImageViews side by side.
It is very fast since there is no paletteization

Code: [Select]
    // Frame Processor Delegate method, will be called each time a rendered frame is produced
    public void onFrameProcessed(final RenderedImage renderedImage){

        if (renderedImage.imageType == RenderedImage.ImageType.VisualJPEGImage) {
            visualBitmap = renderedImage.getBitmap();
            updateVisualImageView(visualBitmap);
            Log.i("app", "Visual Image");
        }

        if (renderedImage.imageType == RenderedImage.ImageType.ThermalLinearFlux14BitImage) {    // seems ot come here for thermal image as well
            thermalBitmap = renderedImage.getBitmap();
            updateThermalImageView(thermalBitmap);
            Log.i("app","Thermal Image");
        }


    }
« Last Edit: November 20, 2015, 01:23:23 am by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #36 on: November 20, 2015, 04:44:21 pm »
BUT there is no way for the delegate to determine what type of image it is UNLESS you modify Renderimage.java to make ImageType public

    public ImageType imageType; 

see my sample code above for saving the ThermalLinearFlux14BitImage to disk ;)

in flironesdk\RenderedImage.java you find:
Code: [Select]
public ImageType imageType()
    {
        return this.imageType;
    }

public byte[] pixelData()
    {
        return this.pixelData;
    }


so you must use brackets:
Code: [Select]
if (renderedImage.imageType() == RenderedImage.ImageType.ThermalLinearFlux14BitImage){
...
                            fop = new FileOutputStream(file);
                            byte[] LeptonRAWBytes = renderedImage.pixelData();
                            fop.write(LeptonRAWBytes);

« Last Edit: November 20, 2015, 05:09:44 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #37 on: November 20, 2015, 05:53:53 pm »
Of course...
This just shows again my lack of programming skills  :P
Thanks for the tip, the app runs just fine.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #38 on: November 20, 2015, 06:31:36 pm »
My programming skills are scary  :-[ (this are my first steps with java).

I haven't found yet a good code template (for linux shell) to grab the frames over usb.

the usb protocol of F1 is similar to the seek


sample 1


It seems extremely simple:
1. Write control transfer on EP0: 0xC0 7E 00 00 (probably does shutter calibration)
2. Read entire frame from EP1. Repeat for a few seconds then recal
 

but the sample code from user sgstair is for windows
I've built some PC side library code to do really basic frame acquisition and calibration based on the data from marshallh's captures, feel free to try it:
https://github.com/sgstair/winusbdotnet

It's winusb based, you should use Zadig to install the winusb driver on the "iAP interface" device that enumerates.

It's not perfect or polished but it does work, I'll probably continue to improve it as I have time.


sample 2
another seek source is here (my hit for linux):
https://github.com/zougloub/libseek

compare the lsusb with the FlirOne (also a iAP Interface and one additional endpoint for frame transfer)
Code: [Select]
  iManufacturer           1 Seek Thermal
  iProduct                2 PIR206 Thermal Camera

      iInterface              3 iAP Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0




      iInterface              4 com.thermal.pir206.1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0


you dual screen is a nice idea  :-+
please post your code for testing
« Last Edit: November 20, 2015, 06:42:57 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #39 on: November 22, 2015, 10:02:46 pm »
Hi cynfab,

with your usb debug file I was able to set a basic configuration and get some telegrams with Ubuntu (modified code from https://github.com/zougloub/libseek )

Code: [Select]

{"type":"sledInformation","data":{"serialNumberBoard":"xxxxxxxxx","partNumberBoard":"xxxxxxxxx","versionBoard":"D","serialNumberLepton":"xxxxxxx","versionLepton":"3.1.46","leptonQR":"xxxxxx","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}

{"type":"batteryVoltageUpdate","data":{"voltage":3.95000004768372,"percentage":76}}

// after power cable plugin
{"type":"batteryChargingCurrentUpdate","data":{"chargingCurrent":500}}
{"type":"batteryChargingStateUpdate","data":{"chargingState":"stateManagedBatteryCharging"}} 


but I can't get a frame with an image.

I'm not sure, if we are missing a command on libusb_control_transfer() to start the frame transfer on endpoint 5.
There is a gab of 17 seconds in your log.
Code: [Select]
[        ]   3.233354 d=  0.000000 [191.7 + 17.317] [  1] NAK

  Here is another capture that starts with the above command & data (different) see below
[        ]  20.832611 d=  0.000001 [231.4 +107.300] [  3] IN   : 89.3
 

Next, I will debug the usb traffic with Android Studio.
« Last Edit: November 22, 2015, 10:09:52 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #40 on: November 23, 2015, 01:12:44 am »
In general the gaps in my log are due to the large number of nak's in between the two ends.
I may have screwed one up.
There is a lot going on in the Flir portocol, I think it is more complex than the Seek, as I was able to get the Seek streaming fairly easily.

I'm still fiddling with my dual view app, but will post the source as soon as I get it looking good enough for my intended use >:D
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #41 on: November 23, 2015, 09:16:18 am »
There is a lot going on in the Flir portocol, I think it is more complex than the Seek, as I was able to get the Seek streaming fairly easily.

Do you have a lightwave source code in c for usb communication?
I use the code from https://github.com/zougloub/libseek, but the c++ code it's more complex as I need for this purpose.

Offline frenky

  • Supporter
  • ****
  • Posts: 971
  • Country: si
    • Frenki.net
Re: Question about FLIR One for Android
« Reply #42 on: November 23, 2015, 11:21:27 am »
Many of the custom apps for Seek also have support for linux: https://github.com/lod/seek-thermal-documentation/wiki/Clients

It might help someone on making a Flir One linux app.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #43 on: November 23, 2015, 12:13:41 pm »
great link, thank you

and there is the requested code "Seek by Cynfab"  ;)


@cynfab
after hours by reading your usb recording ...
and 15 minutes with android studio and debugging over WiFi I got all necessary informations  :-+


// complete handshake of packets which sends the SDK App to FlirOne (write)
Code: [Select]
controlTransfer
protocolType = {UsbCommunicator$ProtocolType@20946} "FRAME"
startCommunication = false

controlTransfer
protocolType = {UsbCommunicator$ProtocolType@20970} "FILEIO"
startCommunication = false

controlTransfer
protocolType = {UsbCommunicator$ProtocolType@20970} "FILEIO"
startCommunication = true

bulkTransfer
protocolType = {UsbCommunicator$ProtocolType@20993} "CONFIGURATION"
data = {byte[16]@20992}
0 = -52 (0xCC)
1 = 1 (0x1)
2 = 0 (0x0)
3 = 0 (0x0)
4 = 1 (0x1)
5 = 0 (0x0)
6 = 0 (0x0)
7 = 0 (0x0)
8 = 65 (0x41)
9 = 0 (0x0)
10 = 0 (0x0)
11 = 0 (0x0)
12 = -8 (0xF8)
13 = -77 (0xB3)
14 = -9 (0xF7)
15 = 0 (0x0)

bulkTransfer
protocolType = {UsbCommunicator$ProtocolType@20992} "CONFIGURATION"
data = {byte[65]@21002}
{"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

bulkTransfer
protocolType = {UsbCommunicator$ProtocolType@20993} "CONFIGURATION"
data = {byte[16]@21044}
0 = -52 (0xCC)
1 = 1 (0x1)
2 = 0 (0x0)
3 = 0 (0x0)
4 = 1 (0x1)
5 = 0 (0x0)
6 = 0 (0x0)
7 = 0 (0x0)
8 = 51 (0x33)
9 = 0 (0x0)
10 = 0 (0x0)
11 = 0 (0x0)
12 = -17 (0xEF)
13 = -37 (0xDB)
14 = -63 (0xC1)
15 = -63 (0xC1)

bulkTransfer
protocolType = {UsbCommunicator$ProtocolType@20993} "CONFIGURATION"
data = {byte[51]@21053}
{"type":"readFile","data":{"streamIdentifier":10}}

controlTransfer
protocolType = {UsbCommunicator$ProtocolType@20946} "FRAME"
startCommunication = true
after this  control transfer we get the frames over EP 5

-------

Control Transfer

source code:

    private static final int SET_INTERFACE = 11;
    static final int CONFIG_READ_ENDPOINT_ID = 1;
    static final int CONFIG_WRITE_ENDPOINT_ID = 2;   // CONFIGURATION
    static final int FILEIO_READ_ENDPOINT_ID = 3;
    static final int FILEIO_WRITE_ENDPOINT_ID = 4;  // only for firmware update
    static final int FRAME_READ_ENDPOINT_ID = 5;

controlTransfer EP0:
    int altSetting = startCommunication ? 1 : 0;
    FILEIO: interfaceNumber = 1;
    FRAME: interfaceNumber = 2;
    int result = this.connection.controlTransfer(1, 0x0B, altSetting, interfaceNumber, null, 0, 200);

you F6d.txt
[        ]   3.221377 d=  0.000000 [179.7 + 40.967] [ 11] DATA0: 01 0b 01 00 02 00 00 00 c4 91
Call to address 78 endpoint 0 Set Interface
Offset Field Value
0 bmRequestType = 01
1 bRequest = 0b
2 wValue 0001 type (H) index (L)
4 wIndex 02
5 wLength 00
6 Data 0000
« Last Edit: November 23, 2015, 04:58:21 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #44 on: November 24, 2015, 11:30:39 pm »
Hi cynfab,

to push this thread I used your python code for seek
https://www.eevblog.com/forum/testgear/yet-another-cheap-thermal-imager-incoming/msg544080/#msg544080
and implemented my knowledge about FlirOne as described above.

Until yet I cannot make a correct bulk write. >:(

But with this code from attachment I get some nice status messages:
Code: [Select]
$ sudo python flir.py
send bytes:16
send bytes:65
array('B', [204, 1, 0, 0, 1, 0, 0, 0, 93, 0, 0, 0, 223, 91, 56, 26])
?]?[8
0x83 usb.core.USBError: [Errno 110] Operation timed out
array('B', [123, 34, 116, 121, 112, 101, 34, 58, 34, 111, 112, 101, 110, 70, 105, 108, 101, 83, 116, 97, 116, 117, 115, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 112, 97, 116, 104, 34, 58, 34, 67, 97, 109, 101, 114, 97, 70, 105, 108, 101, 115, 46, 122, 105, 112, 34, 44, 34, 115, 116, 114, 101, 97, 109, 73, 100, 101, 110, 116, 105, 102, 105, 101, 114, 34, 58, 49, 49, 44, 34, 109, 111, 100, 101, 34, 58, 34, 114, 34, 125, 125, 0])
{"type":"openFileStatus","data":{"path":"CameraFiles.zip","streamIdentifier":11,"mode":"r"}}
0x83 usb.core.USBError: [Errno 110] Operation timed out
array('B', [204, 1, 0, 0, 1, 0, 0,
....
1, 110, 97, 108, 34, 125, 125, 0])
?w`
   ?{"type":"sledInformation","data":{"serialNumberBoard":FFFFFFFFFF","partNumberBoard":"21xxxxxx01","versionBoard":"D","serialNumberLepton":"37xxxx1","versionLepton":"3.1.46","leptonQR":"A0xxxx1","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}
0x83 usb.core.USBError: [Errno 110] Operation timed out
0x81 usb.core.USBError: [Errno 110] Operation timed out
0x83 usb.core.USBError: [Errno 110] Operation timed out
array('B', [204, 1, 0, 0, 1, 0, 0, 0, 84, 0, 0, 0, 85, 20, 48, 103, 123, 34, 116, 121, 112, 101, 34, 58, 34, 98, 97, 116, 116, 101, 114, 121, 86, 111, 108, 116, 97, 103, 101, 85, 112, 100, 97, 116, 101, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 118, 111, 108, 116, 97, 103, 101, 34, 58, 51, 46, 56, 48, 57, 57, 57, 57, 57, 52, 50, 55, 55, 57, 53, 52, 44, 34, 112, 101, 114, 99, 101, 110, 116, 97, 103, 101, 34, 58, 53, 51, 125, 125, 0])
?TU0g{"type":"batteryVoltageUpdate","data":{"voltage":3.80999994277954,"percentage":53}}
0x83 usb.core.USBError: [Errno 110] Operation timed out
array('B', [204, 1, 0, 0, 1, 0, 0, 0, 69, 0, 0, 0, 175, 36, 149, 143, 123, 34, 116, 121, 112, 101, 34, 58, 34, 98, 97, 116, 116, 101, 114, 121, 67, 104, 97, 114, 103, 105, 110, 103, 67, 117, 114, 114, 101, 110, 116, 85, 112, 100, 97, 116, 101, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 99, 104, 97, 114, 103, 105, 110, 103, 67, 117, 114, 114, 101, 110, 116, 34, 58, 48, 125, 125, 0, 204, 1, 0, 0, 1, 0, 0, 0, 81, 0, 0, 0, 103, 228, 238, 80, 123, 34, 116, 121, 112, 101, 34, 58, 34, 98, 97, 116, 116, 101, 114, 121, 67, 104, 97, 114, 103, 105, 110, 103, 83, 116, 97, 116, 101, 85, 112, 100, 97, 116, 101, 34, 44, 34, 100, 97, 116, 97, 34, 58, 123, 34, 99, 104, 97, 114, 103, 105, 110, 103, 83, 116, 97, 116, 101, 34, 58, 34, 115, 116, 97, 116, 101, 78, 111, 67, 104, 97, 114, 103, 105, 110, 103, 34, 125, 125, 0])
?E?$??{"type":"batteryChargingCurrentUpdate","data":{"chargingCurrent":0}}?Qg??P{"type":"batteryChargingStateUpdate","data":{"chargingState":"stateNoCharging"}}
0x83 usb.core.USBError: [Errno 110] Operation timed out
« Last Edit: November 25, 2015, 07:27:59 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #45 on: November 25, 2015, 01:37:18 am »
thomas123,

That's great progress, I'm still dealing with other things and can't fiddle with FlirOne for linux/otherOS stuff for a while.

I'm making progress on my dual view app for android and am almost done enough to post the code. maybe by the week end.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #46 on: December 08, 2015, 10:13:40 pm »
Hi cynfab,

After two weeks hacking the Flir One G2 Android I need your help:

I rechecked all bytes in your dump files F6c.txt and F7c.txt and wrote a C code to exact replay all your sniffed USB packets with libusb.
But I get no datas over EP 0x83 (CameraFiles.zip )and EP 0x85 (frames)  |O

Please, can you make with your OpenVizsla a fresh uncut dump of a SDK.apk start process and also a dump of the USB packets of my code ?
Then can I see the difference.

I have a conjecture, that there is a knocking key to open the frame endpoint of Flir One.
See the mystic order of getting the strings descriptors and a libusb_set_configuration(devh, 3) in the middle:
Code: [Select]
libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEF03FXXXXAFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"

The c code is simple with many comments and prints. You can compile it on Linux and OSX (after installing libusb 1.0).
I goes from python code to c code, because I want direct access to libusb to avoid extra USB traffic.


compile on Mac OSX
Code: [Select]
$ gcc -L/opt/local/lib/ -I/opt/local/include/libusb-1.0/ -o flir flir7d.c  -lusb-1.0after installing libusb 1.0 with mac port
Code: [Select]
$ sudo port install libusb
$ sudo port install libusb-legacy


or compile on Ubuntu
Code: [Select]
$ lsb_release -r
Release: 14.04
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -o flir flir7d.c  -lusb-1.0

and start with
$ sudo ./flir


the current output of the code (EP 0x81 works fine):
Code: [Select]
./flir
Successfully find the Flir One G2 device

libusb_control_transfer(devh, DATA0: 80 | 06 | 00 01 | 00 00 | 12 00
DATA1:  12 01 00 02 00 00 00 40 cb 09 96 19 08 01 01 02 03 01

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 09 00
DATA1:  09 02 60 00 03 03 04 c0 00

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 60 00
DATA1:  09 02 60 00 03 03 04 c0 00 09 04 00 00 02 ff f0 00 05 07 05 81 02 00 02 00 07 05 02 02 00 02 01 09 04 01 01 00 ff f0 01 06 09 04 01 00 02 ff f0 01 06 07 05 83 02 00 02 00 07 05 04 02 00 02 01 09 04 02 01 00 ff f0 01 07 09 04 02 00 02 ff f0 01 07 07 05 85 02 00 02 00 07 05 06 02 00 02 01

libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEF03FXXXXXFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

: Tue Dec  8 22:41:23 2015

: Tue Dec  8 22:41:23 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_TIMEOUT

: Tue Dec  8 22:41:24 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_OTHER

: Tue Dec  8 22:41:25 2015
 bulk read EP 0x81, actual length 535
HEX:
 cc 01 00 00 01 00 00 00 07 02 00 00 77 60 0c bd 7b 22 74 79 70 65 22 3a 22 73 6c 65 64 49 6e 66 6f 72 6d 61 74 69 6f 6e 22 2c 22 64 61 74 61 22 3a 7b 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 46 30 33 46 38 4f 30 30 41 46 46 22 2c 22 70 61 72 74 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 32 31 32 30 30 31 36 30 32 30 31 22 2c 22 76 65 72 73 69 6f 6e 42 6f 61 72 64 22 3a 22 44 22 2c 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 4c 65 70 74 6f 6e 22 3a 22 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 4c 65 70 74 6f 6e 22 3a 22 33 2e 31 2e 34 36 22 2c 22 6c 65 70 74 6f 6e 51 52 22 3a 22 41 30 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 46 61 63 74 6f 72 79 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 4f 70 65 72 61 74 69 6f 6e 61 6c 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 55 70 64 61 74 65 72 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 41 50 49 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 67 69 74 52 65 76 69 73 69 6f 6e 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 61 75 74 6f 6d 61 74 69 63 53 68 75 74 74 65 72 22 3a 22 59 22 2c 22 66 6f 72 6d 46 61 63 74 6f 72 22 3a 22 64 6f 6e 67 6c 65 22 2c 22 74 68 65 72 6d 61 6c 48 65 69 67 68 74 22 3a 22 31 32 30 22 2c 22 74 68 65 72 6d 61 6c 57 69 64 74 68 22 3a 22 31 36 30 22 2c 22 62 69 67 45 6e 64 69 61 6e 54 68 65 72 6d 61 6c 22 3a 22 30 22 2c 22 6f 70 65 72 61 74 69 6e 67 4d 6f 64 65 22 3a 22 6f 70 65 72 61 74 69 6f 6e 61 6c 22 7d 7d 00
STRING:
?w`?{"type":"sledInformation","data":{"serialNumberBoard":"F03XXXXXXX","partNumberBoard":"21222222201","versionBoard":"D","serialNumberLepton":"32333331","versionLepton":"3.1.46","leptonQR":"A0777781","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}

: Tue Dec  8 22:41:25 2015
 bulk read EP 0x81, actual length 100
HEX:
 cc 01 00 00 01 00 00 00 54 00 00 00 55 14 30 67 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 56 6f 6c 74 61 67 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 76 6f 6c 74 61 67 65 22 3a 34 2e 30 31 39 39 39 39 39 38 30 39 32 36 35 31 2c 22 70 65 72 63 65 6e 74 61 67 65 22 3a 39 35 7d 7d 00
STRING:
?TU0g{"type":"batteryVoltageUpdate","data":{"voltage":4.01999998092651,"percentage":95}}

: Tue Dec  8 22:41:25 2015
 bulk read EP 0x81, actual length 182
HEX:
 cc 01 00 00 01 00 00 00 45 00 00 00 af 24 95 8f 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 43 68 61 72 67 69 6e 67 43 75 72 72 65 6e 74 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 63 68 61 72 67 69 6e 67 43 75 72 72 65 6e 74 22 3a 30 7d 7d 00 cc 01 00 00 01 00 00 00 51 00 00 00 67 e4 ee 50 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 43 68 61 72 67 69 6e 67 53 74 61 74 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 63 68 61 72 67 69 6e 67 53 74 61 74 65 22 3a 22 73 74 61 74 65 4e 6f 43 68 61 72 67 69 6e 67 22 7d 7d 00
STRING:
?E?$??{"type":"batteryChargingCurrentUpdate","data":{"chargingCurrent":0}}?Qg??P{"type":"batteryChargingStateUpdate","data":{"chargingState":"stateNoCharging"}}

ask for CameraFiles.zip on EP 0x83:

: Tue Dec  8 22:41:26 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Tue Dec  8 22:41:26 2015

: Tue Dec  8 22:41:26 2015
 bulk read EP 0x81, actual length 109
HEX:
 cc 01 00 00 01 00 00 00 5d 00 00 00 df 5b 38 1a 7b 22 74 79 70 65 22 3a 22 6f 70 65 6e 46 69 6c 65 53 74 61 74 75 73 22 2c 22 64 61 74 61 22 3a 7b 22 70 61 74 68 22 3a 22 43 61 6d 65 72 61 46 69 6c 65 73 2e 7a 69 70 22 2c 22 73 74 72 65 61 6d 49 64 65 6e 74 69 66 69 65 72 22 3a 31 30 2c 22 6d 6f 64 65 22 3a 22 72 22 7d 7d 00
STRING:
?]?[8{"type":"openFileStatus","data":{"path":"CameraFiles.zip","streamIdentifier":10,"mode":"r"}}

: Tue Dec  8 22:41:28 2015

Ask for video stream, start EP 0x85:

: Tue Dec  8 22:41:28 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x85: LIBUSB_ERROR_OTHER
« Last Edit: December 08, 2015, 10:30:38 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #47 on: December 09, 2015, 05:46:50 pm »
Sorry I missed your post yesterday, I'll see if I can do some dumps using my OV.
Give me a few days as things are real busy right now.

   ...ken...
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #48 on: December 09, 2015, 05:56:35 pm »
Here is what my linux box shows for the output of your code:

Code: [Select]
$ sudo ./flir
[sudo] password for kenm:
Successfully find the Flir One G2 device

libusb_control_transfer(devh, DATA0: 80 | 06 | 00 01 | 00 00 | 12 00
DATA1:  12 01 00 02 00 00 00 40 cb 09 96 19 08 01 01 02 03 01

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 09 00
DATA1:  09 02 60 00 03 03 04 c0 00

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 60 00
DATA1:  09 02 60 00 03 03 04 c0 00 09 04 00 00 02 ff f0 00 05 07 05 81 02 00 02 00 07 05 02 02 00 02 01 09 04 01 01 00 ff f0 01 06 09 04 01 00 02 ff f0 01 06 07 05 83 02 00 02 00 07 05 04 02 00 02 01 09 04 02 01 00 ff f0 01 07 09 04 02 00 02 ff f0 01 07 07 05 85 02 00 02 00 07 05 06 02 00 02 01

libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEF03F62xxxxxxxF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

: Wed Dec  9 10:50:57 2015

: Wed Dec  9 10:50:57 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_IO

: Wed Dec  9 10:50:58 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_NO_DEVICE

: Wed Dec  9 10:50:59 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_NO_DEVICE

ask for CameraFiles.zip on EP 0x83:

: Wed Dec  9 10:51:00 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Error in write! res = -4 and transferred = 0

EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Error in write! res = -4 and transferred = 0

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Error in write! res = -4 and transferred = 0

EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Error in write! res = -4 and transferred = 0

: Wed Dec  9 10:51:00 2015

: Wed Dec  9 10:51:00 2015

Ask for video stream, start EP 0x85:
Control Out error -4

Looks to be different from what you get.
I'm using the latest Linux Mint 17.3:

$ lsb_release -r
Release:   17.3

I have not poked at any of this yet so I may have something messed up.


   ...ken...
« Last Edit: December 09, 2015, 05:58:18 pm by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #49 on: December 09, 2015, 09:24:46 pm »
Thanks for your attempt!

Your Linux Mint successful claimed the interfaces 0,1,2 but got on Endpoints 0x02, 0x83 and 0x85 a LIBUSB_ERROR_NO_DEVICE = -4.
Do you unplugged the Flir1 before running "sudo ./flir" ?

I will self install Linux Mint 17.3 and see inside the code...

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #50 on: December 09, 2015, 11:09:54 pm »
I've been trying to figure this out all afternoon and haven't so far. No I didn't unplug the device. I get the same basic response when I try my seek python code moded for the flir one.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #51 on: December 09, 2015, 11:31:10 pm »

After installing a fresh Linux Mint I can write on EP 0x02

install necessary packages (libusb.h, errno.h):
Code: [Select]
$ lsb_release -r
Release: 17.3
$ sudo apt-get install libusb-1.0-0-dev
$ sudo apt-get install g++

compile
Code: [Select]
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -I/usr/include/ -o flir flir7d.c  -lusb-1.0
run
Code: [Select]
$ sudo ./flir
Successfully find the Flir One G2 device

libusb_control_transfer(devh, DATA0: 80 | 06 | 00 01 | 00 00 | 12 00
DATA1:  12 01 00 02 00 00 00 40 cb 09 96 19 08 01 01 02 03 01

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 09 00
DATA1:  09 02 60 00 03 03 04 c0 00

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 60 00
DATA1:  09 02 60 00 03 03 04 c0 00 09 04 00 00 02 ff f0 00 05 07 05 81 02 00 02 00 07 05 02 02 00 02 01 09 04 01 01 00 ff f0 01 06 09 04 01 00 02 ff f0 01 06 07 05 83 02 00 02 00 07 05 04 02 00 02 01 09 04 02 01 00 ff f0 01 07 09 04 02 00 02 ff f0 01 07 07 05 85 02 00 02 00 07 05 06 02 00 02 01

libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEF03FXXXXXXFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

: Thu Dec 10 00:41:50 2015

: Thu Dec 10 00:41:50 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_TIMEOUT

: Thu Dec 10 00:41:51 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_TIMEOUT

: Thu Dec 10 00:41:54 2015
 bulk read EP 0x81, actual length 97
HEX:
 cc 01 00 00 01 00 00 00 51 00 00 00 67 e4 ee 50 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 43 68 61 72 67 69 6e 67 53 74 61 74 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 63 68 61 72 67 69 6e 67 53 74 61 74 65 22 3a 22 73 74 61 74 65 4e 6f 43 68 61 72 67 69 6e 67 22 7d 7d 00
STRING:
?Qg??P{"type":"batteryChargingStateUpdate","data":{"chargingState":"stateNoCharging"}}

ask for CameraFiles.zip on EP 0x83:

: Thu Dec 10 00:41:57 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Thu Dec 10 00:41:57 2015

: Thu Dec 10 00:41:57 2015
 bulk read EP 0x81, actual length 109
HEX:
 cc 01 00 00 01 00 00 00 5d 00 00 00 df 5b 38 1a 7b 22 74 79 70 65 22 3a 22 6f 70 65 6e 46 69 6c 65 53 74 61 74 75 73 22 2c 22 64 61 74 61 22 3a 7b 22 70 61 74 68 22 3a 22 43 61 6d 65 72 61 46 69 6c 65 73 2e 7a 69 70 22 2c 22 73 74 72 65 61 6d 49 64 65 6e 74 69 66 69 65 72 22 3a 31 30 2c 22 6d 6f 64 65 22 3a 22 72 22 7d 7d 00
STRING:
?]?[8{"type":"openFileStatus","data":{"path":"CameraFiles.zip","streamIdentifier":10,"mode":"r"}}

: Thu Dec 10 00:42:01 2015

Ask for video stream, start EP 0x85:

: Thu Dec 10 00:42:01 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x85: LIBUSB_ERROR_TIMEOUT

same result: no packages from EP 83 and 85  :-\



interesting:
on OSX and ubuntu I get after starting the interface 1 with libusb_control_transfer(devh,1,0x0b,1,1,data,0,100) this long status message (like in your log F6c.txt)
Code: [Select]
start interface 1 FILEIO

: Tue Dec  8 22:41:25 2015
 bulk read EP 0x81, actual length 535
HEX:
 cc 01 00 00 01 00 00 00 07 02 00 00 77 60 0c bd 7b 22 74 79 70 65 22 3a 22 73 6c 65 64 49 6e 66 6f 72 6d 61 74 69 6f 6e 22 2c 22 64 61 74 61 22 3a 7b 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 46 30 33 46 38 4f 30 30 41 46 46 22 2c 22 70 61 72 74 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 32 31 32 30 30 31 36 30 32 30 31 22 2c 22 76 65 72 73 69 6f 6e 42 6f 61 72 64 22 3a 22 44 22 2c 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 4c 65 70 74 6f 6e 22 3a 22 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 4c 65 70 74 6f 6e 22 3a 22 33 2e 31 2e 34 36 22 2c 22 6c 65 70 74 6f 6e 51 52 22 3a 22 41 30 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 46 61 63 74 6f 72 79 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 4f 70 65 72 61 74 69 6f 6e 61 6c 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 55 70 64 61 74 65 72 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 41 50 49 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 67 69 74 52 65 76 69 73 69 6f 6e 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 61 75 74 6f 6d 61 74 69 63 53 68 75 74 74 65 72 22 3a 22 59 22 2c 22 66 6f 72 6d 46 61 63 74 6f 72 22 3a 22 64 6f 6e 67 6c 65 22 2c 22 74 68 65 72 6d 61 6c 48 65 69 67 68 74 22 3a 22 31 32 30 22 2c 22 74 68 65 72 6d 61 6c 57 69 64 74 68 22 3a 22 31 36 30 22 2c 22 62 69 67 45 6e 64 69 61 6e 54 68 65 72 6d 61 6c 22 3a 22 30 22 2c 22 6f 70 65 72 61 74 69 6e 67 4d 6f 64 65 22 3a 22 6f 70 65 72 61 74 69 6f 6e 61 6c 22 7d 7d 00
STRING:
?w`?{"type":"sledInformation","data":{"serialNumberBoard":"F03XXXXXXX","partNumberBoard":"21222222201","versionBoard":"D","serialNumberLepton":"32333331","versionLepton":"3.1.46","leptonQR":"A0777781","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}
.. but not with Mint  :-\



edit: randomly I get a full message with Mint:
maybe trouble with virtual machine (linux mint runs under vmware fusion)
Code: [Select]
$ sudo ./flir
Successfully find the Flir One G2 device

libusb_control_transfer(devh, DATA0: 80 | 06 | 00 01 | 00 00 | 12 00
DATA1:  12 01 00 02 00 00 00 40 cb 09 96 19 08 01 01 02 03 01

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 09 00
DATA1:  09 02 60 00 03 03 04 c0 00

libusb_control_transfer(devh, DATA0: 80 06 00 02 00 00 60 00
DATA1:  09 02 60 00 03 03 04 c0 00 09 04 00 00 02 ff f0 00 05 07 05 81 02 00 02 00 07 05 02 02 00 02 01 09 04 01 01 00 ff f0 01 06 09 04 01 00 02 ff f0 01 06 07 05 83 02 00 02 00 07 05 04 02 00 02 01 09 04 02 01 00 ff f0 01 07 09 04 02 00 02 ff f0 01 07 07 05 85 02 00 02 00 07 05 06 02 00 02 01

libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEF03F8O00AFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

: Thu Dec 10 00:50:29 2015

: Thu Dec 10 00:50:29 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_TIMEOUT

: Thu Dec 10 00:50:30 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_TIMEOUT

: Thu Dec 10 00:50:32 2015
 bulk read EP 0x81, actual length 519
HEX:
 7b 22 74 79 70 65 22 3a 22 73 6c 65 64 49 6e 66 6f 72 6d 61 74 69 6f 6e 22 2c 22 64 61 74 61 22 3a 7b 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 46 30 33 46 38 4f 30 30 41 46 46 22 2c 22 70 61 72 74 4e 75 6d 62 65 72 42 6f 61 72 64 22 3a 22 32 31 32 30 30 31 36 30 32 30 31 22 2c 22 76 65 72 73 69 6f 6e 42 6f 61 72 64 22 3a 22 44 22 2c 22 73 65 72 69 61 6c 4e 75 6d 62 65 72 4c 65 70 74 6f 6e 22 3a 22 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 4c 65 70 74 6f 6e 22 3a 22 33 2e 31 2e 34 36 22 2c 22 6c 65 70 74 6f 6e 51 52 22 3a 22 41 30 33 37 31 38 37 31 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 46 61 63 74 6f 72 79 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 4f 70 65 72 61 74 69 6f 6e 61 6c 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 55 70 64 61 74 65 72 45 53 57 22 3a 22 30 2e 34 2e 32 37 22 2c 22 76 65 72 73 69 6f 6e 52 6f 73 65 62 75 64 41 50 49 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 67 69 74 52 65 76 69 73 69 6f 6e 22 3a 22 6d 61 73 74 65 72 2e 30 31 35 65 64 65 34 22 2c 22 61 75 74 6f 6d 61 74 69 63 53 68 75 74 74 65 72 22 3a 22 59 22 2c 22 66 6f 72 6d 46 61 63 74 6f 72 22 3a 22 64 6f 6e 67 6c 65 22 2c 22 74 68 65 72 6d 61 6c 48 65 69 67 68 74 22 3a 22 31 32 30 22 2c 22 74 68 65 72 6d 61 6c 57 69 64 74 68 22 3a 22 31 36 30 22 2c 22 62 69 67 45 6e 64 69 61 6e 54 68 65 72 6d 61 6c 22 3a 22 30 22 2c 22 6f 70 65 72 61 74 69 6e 67 4d 6f 64 65 22 3a 22 6f 70 65 72 61 74 69 6f 6e 61 6c 22 7d 7d 00
STRING:
{"type":"sledInformation","data":{"serialNumberBoard":"F03FXXXXXXFF","partNumberBoard":"211111111","versionBoard":"D","serialNumberLepton":"3222221","versionLepton":"3.1.46","leptonQR":"A3444441","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}

ask for CameraFiles.zip on EP 0x83:

: Thu Dec 10 00:50:36 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Thu Dec 10 00:50:36 2015

: Thu Dec 10 00:50:36 2015
 bulk read EP 0x81, actual length 16
HEX:
 cc 01 00 00 01 00 00 00 5d 00 00 00 df 5b 38 1a
STRING:
?]?[8

« Last Edit: December 10, 2015, 12:07:11 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #52 on: December 10, 2015, 12:03:56 am »
Very interesting, I just tried on a laptop and got the same results as I got before, this was a 32bit laptop and before I was using my 64bit desktop.
I find it interesting that I get different error messages.
Maybe my Flir One has different fiirmware.
THe FlirOne app says I have vers 0.4.26
and vers 1.4.1 fro the app.
Hardware version C

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #53 on: December 10, 2015, 12:06:57 am »
my F1: "versionBoard":"D"
your F1: "versionBoard":"C"

As I wrote above I changed from phyton to c because c has a native access to libusb without overhead.
I tried to write the same bytes to usb as I read in your log file.
I hope your OpenVizsla can show the difference.

PS: I installed 64 Bit Linux Mint

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #54 on: December 10, 2015, 12:21:04 am »
What version of libusb-1.0 are you using, mine is what comes with Linux Mint 17.3 which is:
2:1.0.17-1ubuntu2
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #55 on: December 10, 2015, 12:46:44 am »
Here is an OV dump of my laptop talking to the FlirOne using your code.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #56 on: December 10, 2015, 09:42:23 am »
Great :-+

The good news: Our USB packets from c-code are byte identical (include checksum) with the Flir One App
The bad news: You can't start with your Linux Mint the EP 0x81 (CONFIG_READ_ENDPOINT) on interface 0 of the Flir1. Therefore you got an error and the transfer stops.

Lets compare our configuration:

I downloaded the linuxmint-17.3-cinnamon-64bit.iso from http://www.linuxmint.com/download.php
and after installing in vmware :D I only make the following steps for running the code:
Code: [Select]
$ sudo apt-get install libusb-1.0-0-dev
$ sudo apt-get install g++

$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -I/usr/include/ -o flir flir7d.c  -lusb-1.0

then I can open the EP 0x81 as you see in my log files above
 
Code: [Select]
bulk read EP 0x81, actual length 519
...
STRING:
{"type":"sledInformation","data":{"serialNumberBoard":"F03FXXXXXXFF","partNumberBoard":"211111111","versionBoard":"D","serialNumberLepton":"3222221","versionLepton":"3.1.46","leptonQR":"A3444441","versionRosebudFactoryESW":"0.4.27","versionRosebudOperationalESW":"0.4.27","versionRosebudUpdaterESW":"0.4.27","versionRosebudAPI":"master.015ede4","gitRevision":"master.015ede4","automaticShutter":"Y","formFactor":"dongle","thermalHeight":"120","thermalWidth":"160","bigEndianThermal":"0","operatingMode":"operational"}}

my libusb version is the same as yours (2:1.0.17-1ubuntu2):
Code: [Select]
$ dpkg -l | grep -i usb
...
ii  libusb-0.1-4:amd64                          2:0.1.12-23.3ubuntu1                                amd64        userspace USB programming library
ii  libusb-1.0-0:amd64                          2:1.0.17-1ubuntu2                                   amd64        userspace USB programming library
ii  libusb-1.0-0:i386                           2:1.0.17-1ubuntu2                                   i386         userspace USB programming library
ii  libusb-1.0-0-dev:amd64                      2:1.0.17-1ubuntu2                                   amd64        userspace USB programming library development files

it's possible, that you included a bad lib path with your gcc
please compare you command line with my line:
Code: [Select]
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -I/usr/include/ -o flir flir7d.c  -lusb-1.0
Maybe that a claim interface with "force" make sense, but I got an ok!
http://developer.android.com/reference/android/hardware/usb/UsbDeviceConnection.html#claimInterface(android.hardware.usb.UsbInterface,%20boolean)
« Last Edit: December 10, 2015, 09:58:31 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #57 on: December 10, 2015, 05:05:47 pm »
I use Linux mint as my main desktop, so no vmware involved. I am using Mint 17.3 MATE
I have lots of stuff installed so it is possible that there is some sort of usb conflict.
I already had libusb-1.0-0-dev and build essentials installed so after executing your 2 apt-get commands apt reported nothing further installed.
I cut and pasted your compile command.

 dpkg -l | grep -i usb
ii  libgusb2:amd64                              0.1.6-5                                                     amd64        GLib wrapper around libusb1
ii  libusb-0.1-4:amd64                          2:0.1.12-23.3ubuntu1                                        amd64        userspace USB programming library
ii  libusb-1.0-0:amd64                          2:1.0.17-1ubuntu2                                           amd64        userspace USB programming library
ii  libusb-1.0-0:i386                           2:1.0.17-1ubuntu2                                           i386         userspace USB programming library
ii  libusb-1.0-0-dev:amd64                      2:1.0.17-1ubuntu2                                           amd64        userspace USB programming library development files
ii  libusbmuxd2                                 1.0.8-2ubuntu1                                              amd64        USB multiplexor daemon for iPhone and iPod Touch devices - library
ii  mintstick                                   1.2.6                                                       all          write .img and .iso files to USB sticks
ii  python-usb                                  0.4.3-1                                                     amd64        USB interface for Python
ii  usb-modeswitch                              2.1.1+repack0-1ubuntu1                                      amd64        mode switching tool for controlling "flip flop" USB devices
ii  usb-modeswitch-data                         20140327-1                                                  all          mode switching data for usb-modeswitch
ii  usbmuxd                                     1.0.8-2ubuntu1                                              amd64        USB multiplexor daemon for iPhone and iPod Touch devices
ii  usbutils                                    1:007-2ubuntu1                                              amd64        Linux USB utilities
ii  xserver-xorg-video-sisusb                   1:0.9.6-2build1                                             amd64        X.Org X server -- SiS USB display driver

I think my lib path is ok as ldd seems to find the libusb-1.0 lib


 ldd flir
   linux-vdso.so.1 =>  (0x00007ffcdd786000)
   libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f6e74610000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6e7424b000)
   libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f6e74039000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6e73e1b000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f6e74852000)
   libcgmanager.so.0 => /lib/x86_64-linux-gnu/libcgmanager.so.0 (0x00007f6e73c00000)
   libnih.so.1 => /lib/x86_64-linux-gnu/libnih.so.1 (0x00007f6e739e7000)
   libnih-dbus.so.1 => /lib/x86_64-linux-gnu/libnih-dbus.so.1 (0x00007f6e737dd000)
   libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f6e73598000)
   librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6e7338f000)

I'll tried to use the FORCE  boolean and it makes no difference.  oops, that's only for android, my bad...;>P

could you send me your flir binary.
« Last Edit: December 10, 2015, 06:23:37 pm by cynfab »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #58 on: December 10, 2015, 07:39:54 pm »
It's working on my system now,
I removed the lsusb_reset_device from main, and added a few prints to see what was going on and it's now reading data from EP 85!!
I think the reset device was screwing things up (differently) on our respective systems.
Now we can move on to do some real Thermal Imaging.
   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #59 on: December 10, 2015, 10:58:34 pm »
... and it's now reading data from EP 85!!

wow :-+

Really from EP 0x85 ? Please send me a terminal log from your F1 :palm:

I used your changed code on Mint and OSX ... and nothing happens on EP 0x83 and 0x85 ...
Code: [Select]
>>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_OTHER
>>>>>>>>>>>>>>>>>bulk transfer (in) 0x85: LIBUSB_ERROR_OTHER

As I said, I rechecked every USB byte twice and I have the suspicion that there is a special sequence for opening the endpoint 0x85 like port knocking
https://en.wikipedia.org/wiki/Port_knocking.

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #60 on: December 11, 2015, 01:16:52 am »
took out some of the prints so the dump of the data from EP 85 wouldn't overwhelm my terminal.

Here is the terminal log and the code that generated it.

I would still like to try your binary.

  ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #61 on: December 11, 2015, 11:20:14 am »
as attachment my binary and terminal log

I'm interested in your binary  ;)

Code: [Select]
$ ldd flir
linux-vdso.so.1 =>  (0x00007ffd3e51a000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fd5a8e9a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd5a8ad5000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fd5a88c4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd5a86a6000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd5a90b1000)
libcgmanager.so.0 => /lib/x86_64-linux-gnu/libcgmanager.so.0 (0x00007fd5a848b000)
libnih.so.1 => /lib/x86_64-linux-gnu/libnih.so.1 (0x00007fd5a8273000)
libnih-dbus.so.1 => /lib/x86_64-linux-gnu/libnih-dbus.so.1 (0x00007fd5a8069000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fd5a7e24000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd5a7c1c000)
... no differences to your "ldd flir"
« Last Edit: December 11, 2015, 02:28:50 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #62 on: December 11, 2015, 11:31:04 am »
Hi cynfab,

please check, if your code is also working fine after changing the order of the string descriptors
a[8] = { 2,1,3,4,5,6,7};
and
if (a==3){
          r = libusb_set_configuration(devh, 3);

this part give as result:
Code: [Select]
libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEFXXXXXXXFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"

Code: [Select]
    int  a[8] = { 2,1,3,4,5,6,7};
   
// Get all string descriptors.
for (i = 0; i <= 6; i++)
{

    r = libusb_get_string_descriptor(devh, a[i], langid, tbuf, 0xFF);

if (r >= 0)
{
//printf("String descriptor %u: \"%s\"\n", a[i], string_buffer);
int si, di;

for (di = 0, si = 2; si < tbuf[0]; si += 2) {
        if ((tbuf[si] & 0x80) || (tbuf[si + 1])) /* non-ASCII */
        string_buffer[di++] = '?';
        else
        string_buffer[di++] = tbuf[si];
        }
        string_buffer[di] = 0;
printf("String descriptor %u: \"%s\"\n", a[i], string_buffer);


} else {
fprintf(stderr, "libusb_get_string_descriptor wValue=%i error %d\n", a[i], r);
      goto out;
}

// after string_descriptor 0303 comes SET_CONFIGURATION = 03
if (a[i]==3){
r = libusb_set_configuration(devh, 3);
        if (r < 0) {
          fprintf(stderr, "libusb_set_configuration error %d\n", r);
          goto out;
          }
          printf("Successfully set usb configuration 3\n");

}
}

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #63 on: December 11, 2015, 03:11:49 pm »
Hi tomas123,
Your binary runs ok on my system. i.e. it reads from EP 83 & 85.
log attached.
Of interest is that I ran the code twice and the first time it got Camerafiles.zip from the device, the second time it did not. The camera was powered on continuously and the runs were less than a minuet apart.

Do you want me to change the order of descriptors? the code you posted is identical to what I have now.
I'll change it if you like, please say to what.
I don't think the order is the same as what I observed with my OV.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #64 on: December 11, 2015, 04:24:13 pm »
this is exact the mystic order, which you have logged in F6c.txt:

Code: [Select]
libusb_get_string_descriptor langid=0x409
String descriptor 2: "FLIR ONE Camera"
String descriptor 1: "FLIR Systems"
String descriptor 3: "FLIRONEFXXXXXXXFFF"
Successfully set usb configuration 3
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"

from your log F6c.txt:
Code: [Select]
0 bmRequestType = 80
1 bRequest = 06                          GET_DESCRIPTOR
2 wValue 0300 type (H) index (L)          type: String Descriptor (0x03)  // http://www.beyondlogic.org/usbnutshell/usb5.shtml#StringDescriptors
4 wIndex 00
5 wLength 00
DATA0: 80 06 00 03 00 00 ff 00 d4 64
-> String Descriptor result
     Offset Field Value
     0 bLength = 04
     1 bDescriptorType = 03
     2 bString 0409

 
--
0 bmRequestType = 80
1 bRequest = 06                     GET_DESCRIPTOR
2 wValue 0302 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 02 03 09 04 ff 00 97 db
-> String Descriptor result (FLIR ONE Camera)


--
0 bmRequestType = 80
1 bRequest = 06                     GET_DESCRIPTOR
2 wValue 0301 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 01 03 09 04 ff 00 97 e8
-> String Descriptor result (FLIR SYSTEMS)

--
0 bmRequestType = 80
1 bRequest = 06                     GET_DESCRIPTOR
2 wValue 0303 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 03 03 09 04 ff 00 96 0a
-> String Descriptor result (FLIRONEF03F6200xxxx)

--
0 bmRequestType = 00
1 bRequest = 09                     SET_CONFIGURATION     03
2 wValue 0003 type (H) index (L)
4 wIndex 00
5 wLength 00
DATA0: 00 09 03 00 00 00 00 00 26 c7

--
0 bmRequestType = 80
1 bRequest = 06                    GET_DESCRIPTOR
2 wValue 0304 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 04 03 09 04 ff 00 97 bd
-> String Descriptor result (SBI BDP Configuration)

--
0 bmRequestType = 80
1 bRequest = 06                    GET_DESCRIPTOR
2 wValue 0305 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 05 03 09 04 ff 00 96 6c
-> String Descriptor result (iAP Interface)

--
0 bmRequestType = 80
1 bRequest = 06                    GET_DESCRIPTOR
2 wValue 0306 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 06 03 09 04 ff 00 96 5f
-> String Descriptor result (com.flir.rosebud.fileio)

--
0 bmRequestType = 80
1 bRequest = 06                    GET_DESCRIPTOR
2 wValue 0307 type (H) index (L)
4 wIndex 09
5 wLength 04
DATA0: 80 06 07 03 09 04 ff 00 97 8e
-> String Descriptor result (com.flir.rosebud.frame)

Please change the order, so I know whether it is a key.

Otherwise I have the trouble, the the first different bytes on USB between our cameras is the serial number with "String descriptor 3: "FLIRONEFXXXXXXXFFF"
Is there a key, then it can be only placed after the string descriptor 3.

my suggest for a attempt is:

a[8] = { 1,2,3,4,5,6,7};
and
if (a==7){
          r = libusb_set_configuration(devh, 3);


I also can't find anything magic keys in the Flir One SDK java files. It looks like the magic seqeunce is arranged from the Android operating system (USB handshake).
But in your logfile F6c.txt nobody ask for "bConfigurationValue = 3"  but gives the command  "libusb_set_configuration(dev,0x03)" ... :-//
|O
« Last Edit: December 11, 2015, 04:51:05 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #65 on: December 11, 2015, 04:57:48 pm »
Here is the log, and code
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #66 on: December 11, 2015, 05:29:55 pm »
Great :-+

It's sure, that this changed order is not working??
Do you for test purposes unplugged the F1 from USB? 

Please poke a little around this code piece.
I'm very interested in!!
« Last Edit: December 11, 2015, 05:32:14 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #67 on: December 11, 2015, 05:54:11 pm »
Maybe not so great...
I moved the set config 3 around a bit and it still worked, then set it back to where it was when I last posted, and it worked.....
So I'm not sure what's going on, I'll keep poking at it.
Now that I'm getting frames, it would be nice to be able to see what they look like.
   ...ken...

After running that version several times, sometimes it works, sometimes not.
It seems like you can charge the battery at the same time the camera is running too. This will be good for unattended operation.
« Last Edit: December 11, 2015, 06:12:58 pm by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #68 on: December 11, 2015, 06:16:01 pm »
Hi cynfab,

you are the greatest!!! :-+ :-+
I searched for an old notebook and installed a clean Linux Mint 17 native to disc (no virtual machine).
And now it works fine.

The next step is to search the different between "your" Linux Mint and my systems (Ubuntu, OSX).

Thanks for your help.
« Last Edit: December 11, 2015, 06:17:46 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #69 on: December 11, 2015, 06:29:43 pm »
I found that when it doesn't work:

libusb_get_string_descriptor langid=0x409
String descriptor 1: "FLIR Systems"
String descriptor 2: "FLIR ONE Camera"
String descriptor 3: "FLIRONEF03F6200571F"
String descriptor 4: "SBIBDP Configuration"
String descriptor 5: "iAP Interface"
String descriptor 6: "com.flir.rosebud.fileio"
String descriptor 7: "com.flir.rosebud.frame"
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
stop interface 1 FILEIO
stop interface 2 FRAME

start interface 1 FILEIO
Control Out error -1

If I try to start the interface again r=0, so maybe the start interface section needs to retry if it gets r=-1.

 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #70 on: December 11, 2015, 07:21:38 pm »
Fascinating reading guys. I do not pretend to understand most of it, but I like seeing your team work to solve problems. I hope your efforts are appreciated by others as well. Please keep posting updates as and when you have the time.

Fraser
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #71 on: December 11, 2015, 07:55:02 pm »
The FlirONE is capable of better imaging than the FlirONE app shows.
The SDK is one way to that end, the other will be via the community developing applications that run on something other than Android devices with Flir's closed library.
I'm happy to be able to participate in this effort, as I did in the Seek RE effort.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #72 on: December 11, 2015, 10:42:53 pm »
happy our, on my Raspberry Pi the code also runs fine
I worked the last two weeks at wrong computers  |O

Code: [Select]
$ uname -a
Linux raspberryLCD 3.18.13-v7+ #784 SMP PREEMPT Sat May 9 15:57:36 BST 2015 armv7l GNU/Linux
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -o flir flir7f.c  -lusb-1.0
$ sudo ./flir
...
: Fri Dec 11 23:40:00 2015
 bulk read EP 0x85, actual length 166
HEX:
 7b 22 73 68 75 74 74 65 72 53 74 61 74 65 22 3a 22 4f 4e 22 2c 22 73 68 75 74 74 65 72 54 65 6d 70 65 72 61 74 75 72 65 22 3a 33 31 32 2e 32 33 39 39 39 30 32 33 34 33 37 35 2c 22 75 73 62 4e 6f 74 69 66 69 65 64 54 69 6d 65 73 74 61 6d 70 22 3a 31 31 37 34 36 37 32 30 31 30 2e 35 38 37 34 2c 22 75 73 62 45 6e 71 75 65 75 65 64 54 69 6d 65 73 74 61 6d 70 22 3a 31 31 37 34 36 37 32 30 31 30 2e 35 39 33 35 31 2c 22 66 66 63 53 74 61 74 65 22 3a 22 46 46 43 5f 56 41 4c 49 44 5f 52 41 44 22 7d 00
STRING:
{"shutterState":"ON","shutterTemperature":312.239990234375,"usbNotifiedTimestamp":1174672010.5874,"usbEnqueuedTimestamp":1174672010.59351,"ffcState":"FFC_VALID_RAD"}

: Fri Dec 11 23:40:01 2015
 bulk read EP 0x85, actual length 128208
HEX:
 cf 0b da 0b d2 0b cb 0b c6 0b cd 0b d0 0b cf 0b d2 0b d1 0b d0 0b ca 0b d0 0b cb 0b cb 0b cf 0b cb 0b c6 0b d2 0b cf 0b cd 0b db 0b d5 0b c8 0b cb 0b ce 0b ce 0b cb 0b cd 0b ca 0b d1 0b d1 0b d4 0b ca 0b d9 0b c6 0b ce 0b d6 0b d5 0b cc 0b ca 0b d9 0b c9 0b d5 0b d4 0b d7 0b d3 0b d3 0b cf 0b cf 0b d5 0b d6 0b d1 0b db 0b d7 0b da 0b d2 0b e5 0b e4 0b d3 0b e0 0b d8 0b d6 0b dd 0b e1 0b e8 0b d5 0b dc 0b d9 0b dc 0b de 0b d4 0b d6 0b d9 0b de 0b dc 0b 07 00 b5 7a e2 0b df 0b d8 0b e4 0b d4 0b df 0b d9 0b d8 0b d8 0b d7 0b d7 0b d9 0b e4 0b de 0b e0 0b d7 0b de 0b e3 0b d8 0b e7 0b dc 0b e5 0b e2 0b e6 0b f0 0b ea 0b e0 0b dc 0b de 0b e0 0b d3 0b de 0b d4 0b db 0b da 0b dd 0b e0 0b e2 0b e9 0b e0 0b e5 0b e2 0b ea 0b e2 0b e7 0b e6 0b e2 0b e7 0b e7 0b db 0b e5 0b eb 0b e5 0b e9 0b e8 0b e4 0b ec 0b ee 0b e6 0b e2 0b e5 0b e5 0b e5 0b e4 0b ed 0b de 0b e6 0b e2 0b ee 0b e4 0b f2 0b e8 0b
« Last Edit: December 11, 2015, 11:46:18 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #73 on: December 12, 2015, 01:20:24 am »
As it turns out you can remove the get string descriptors as well as a lot of other stuff and it still "works".
BUT I think there are some timing issues as this code doesn't always work, and sometimes the EP 85 reads come a lot faster than other times.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #74 on: December 12, 2015, 09:22:06 am »
I think, the best way for stable code is to shorten the code exact to the USB initialization sequence of Flir SDK:
- flironesdk/usb/UsbCommunicator.java
- flironesdk/Device.java.

see my attachment flir7h.c

I moved the start/stop interface to state 1
Therefore we get while first loop a non ciritical error
bulk transfer (in) 0x81/0x83: LIBUSB_ERROR_TIMEOUT



Flir One with Raspberry Pi
Code: [Select]
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0' -o flir flir7i.c  -lusb-1.0
analyses of endpoint 0x85 frames 
use flir7i.c for saving the frames to disc, code needs 2/3 frames to sync (simple use only frames > 80Kb):

(1) first image inside the 0x85 frame is the RAW image:
32 Byte Header
then 164x120 2 Byte Little Endian

read with ImageJ http://imagej.nih.gov/ij/download.html
File/Import/RAW

or PS:
https://www.eevblog.com/forum/testgear/actual-resolution-of-flir-one-v2/msg797330/#msg797330

(2) second image is the visible image JPG 640x480
starts at byte 39880 with magic byte sequence  of jpeg "FF 08 FF C0"
Code: [Select]
$ dd if=EP0x85#00005.bin of=1.jpg bs=1 skip=39880
$ identify 1.jpg
1.jpg JPEG 640x480 640x480+0+0 8-bit sRGB 69.3KB 0.000u 0:00.000

(3) at the end a string with some status infomations
Code: [Select]
0001a8b0  ff d9 00 00 00 00 00 00  7b 22 73 68 75 74 74 65  |........{"shutte|
0001a8c0  72 53 74 61 74 65 22 3a  22 4f 4e 22 2c 22 73 68  |rState":"ON","sh|
0001a8d0  75 74 74 65 72 54 65 6d  70 65 72 61 74 75 72 65  |utterTemperature|
0001a8e0  22 3a 33 31 33 2e 35 31  39 39 38 39 30 31 33 36  |":313.5199890136|
0001a8f0  37 32 2c 22 75 73 62 4e  6f 74 69 66 69 65 64 54  |72,"usbNotifiedT|
0001a900  69 6d 65 73 74 61 6d 70  22 3a 31 31 37 34 37 31  |imestamp":117471|
0001a910  36 31 33 35 2e 37 34 35  37 33 2c 22 75 73 62 45  |6135.74573,"usbE|
0001a920  6e 71 75 65 75 65 64 54  69 6d 65 73 74 61 6d 70  |nqueuedTimestamp|
0001a930  22 3a 31 31 37 34 37 31  36 31 33 35 2e 37 34 37  |":1174716135.747|
0001a940  33 36 2c 22 66 66 63 53  74 61 74 65 22 3a 22 46  |36,"ffcState":"F|
0001a950  46 43 5f 56 41 4c 49 44  5f 52 41 44 22 7d 00     |FC_VALID_RAD"}.|

at usbEnqueuedTimestamp you see, that the frame rate is only 5 fps  :(
Code: [Select]
$ strings -n 60 EP0x85*.bin
{"shutterState":"ON","shutterTemperature":313.450012207031,"usbNotifiedTimestamp":1174716129.83373,"usbEnqueuedTimestamp":1174716129.83571,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.459991455078,"usbNotifiedTimestamp":1174716130.15704,"usbEnqueuedTimestamp":1174716130.15865,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.459991455078,"usbNotifiedTimestamp":1174716130.36589,"usbEnqueuedTimestamp":1174716130.36731,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.459991455078,"usbNotifiedTimestamp":1174716130.58713,"usbEnqueuedTimestamp":1174716130.5937,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.470001220703,"usbNotifiedTimestamp":1174716130.80297,"usbEnqueuedTimestamp":1174716130.80479,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.470001220703,"usbNotifiedTimestamp":1174716131.01766,"usbEnqueuedTimestamp":1174716131.0193,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.489990234375,"usbNotifiedTimestamp":1174716131.23305,"usbEnqueuedTimestamp":1174716131.2348,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.489990234375,"usbNotifiedTimestamp":1174716131.44797,"usbEnqueuedTimestamp":1174716131.44984,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.480010986328,"usbNotifiedTimestamp":1174716131.66307,"usbEnqueuedTimestamp":1174716131.6651,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.489990234375,"usbNotifiedTimestamp":1174716131.8858,"usbEnqueuedTimestamp":1174716131.88725,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.5,"usbNotifiedTimestamp":1174716132.1132,"usbEnqueuedTimestamp":1174716132.11485,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.489990234375,"usbNotifiedTimestamp":1174716132.34005,"usbEnqueuedTimestamp":1174716132.34374,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.489990234375,"usbNotifiedTimestamp":1174716132.5623,"usbEnqueuedTimestamp":1174716132.56389,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.5,"usbNotifiedTimestamp":1174716132.79527,"usbEnqueuedTimestamp":1174716132.79729,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.5,"usbNotifiedTimestamp":1174716133.01296,"usbEnqueuedTimestamp":1174716133.01477,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.5,"usbNotifiedTimestamp":1174716133.23994,"usbEnqueuedTimestamp":1174716133.24187,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.510009765625,"usbNotifiedTimestamp":1174716133.4633,"usbEnqueuedTimestamp":1174716133.46513,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716133.67718,"usbEnqueuedTimestamp":1174716133.6789,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716133.89206,"usbEnqueuedTimestamp":1174716133.89397,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.510009765625,"usbNotifiedTimestamp":1174716134.00615,"usbEnqueuedTimestamp":1174716134.00789,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716134.21907,"usbEnqueuedTimestamp":1174716134.22141,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716134.43391,"usbEnqueuedTimestamp":1174716134.43569,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716134.65212,"usbEnqueuedTimestamp":1174716134.65416,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.529998779297,"usbNotifiedTimestamp":1174716134.86733,"usbEnqueuedTimestamp":1174716134.86918,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.540008544922,"usbNotifiedTimestamp":1174716135.08135,"usbEnqueuedTimestamp":1174716135.08307,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.540008544922,"usbNotifiedTimestamp":1174716135.29754,"usbEnqueuedTimestamp":1174716135.29895,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.529998779297,"usbNotifiedTimestamp":1174716135.52014,"usbEnqueuedTimestamp":1174716135.52226,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.519989013672,"usbNotifiedTimestamp":1174716135.74573,"usbEnqueuedTimestamp":1174716135.74736,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.529998779297,"usbNotifiedTimestamp":1174716135.97042,"usbEnqueuedTimestamp":1174716135.97194,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.529998779297,"usbNotifiedTimestamp":1174716136.08966,"usbEnqueuedTimestamp":1174716136.09131,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.540008544922,"usbNotifiedTimestamp":1174716136.3133,"usbEnqueuedTimestamp":1174716136.31491,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":313.529998779297,"usbNotifiedTimestamp":1174716136.52721,"usbEnqueuedTimestamp":1174716136.53921,"ffcState":"FFC_VALID_RAD"}
« Last Edit: December 12, 2015, 03:09:37 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #75 on: December 12, 2015, 04:57:56 pm »
tomas123,
Very nice.
I ran flir7i and it dumped many files before I realized it. Looking at the EP85 ones, I see ones that are pure jpg, some are pure thermal, some are combined, some are shuter state and some are 28 bytes of who knows what.

Code: [Select]
-rw-r--r-- 1 kenm kenm 107921 Dec 12 09:11 EP0x85#00023.bin
-rw-r--r-- 1 kenm kenm  26896 Dec 12 09:11 EP0x85#00024.bin
-rw-r--r-- 1 kenm kenm    168 Dec 12 09:11 EP0x85#00025.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00026.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00027.bin
-rw-r--r-- 1 kenm kenm  63289 Dec 12 09:11 EP0x85#00028.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00029.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00030.bin
-rw-r--r-- 1 kenm kenm  93785 Dec 12 09:11 EP0x85#00031.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00032.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00033.bin
-rw-r--r-- 1 kenm kenm  93385 Dec 12 09:11 EP0x85#00034.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00035.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00036.bin
-rw-r--r-- 1 kenm kenm  93201 Dec 12 09:11 EP0x85#00037.bin
-rw-r--r-- 1 kenm kenm  77944 Dec 12 09:11 EP0x85#00038.bin
-rw-r--r-- 1 kenm kenm    169 Dec 12 09:11 EP0x85#00039.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00040.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00041.bin
-rw-r--r-- 1 kenm kenm 103896 Dec 12 09:11 EP0x85#00042.bin
-rw-r--r-- 1 kenm kenm 124008 Dec 12 09:11 EP0x85#00043.bin
-rw-r--r-- 1 kenm kenm    169 Dec 12 09:11 EP0x85#00044.bin
-rw-r--r-- 1 kenm kenm 132952 Dec 12 09:11 EP0x85#00045.bin
-rw-r--r-- 1 kenm kenm    169 Dec 12 09:11 EP0x85#00046.bin
-rw-r--r-- 1 kenm kenm 116440 Dec 12 09:11 EP0x85#00047.bin
-rw-r--r-- 1 kenm kenm    169 Dec 12 09:11 EP0x85#00048.bin
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00049.bin

EP0x85#00036 thermal
EP0x85#00037 jpg
EP0x85#00038 ???
EP0x85#00039 shutter
EP0x85#00040 28 byte ???
EP0x85#00043 combined

Or maybe I'm missing something
« Last Edit: December 12, 2015, 05:10:56 pm by cynfab »
 

Offline sonic

  • Contributor
  • Posts: 37
  • Country: de
    • Homepage
Remote thermal cam
« Reply #76 on: December 12, 2015, 05:36:27 pm »
[...]it was usable on the PC as a webcam.

I did this with the help of SmartCam. I modified the Android SDK example to send a MJPEG stream to it via WiFi. Details on my website.
« Last Edit: January 10, 2016, 02:29:49 am by sonic »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #77 on: December 13, 2015, 08:43:53 am »
Hi sonic,

good work  :-+ :-+

Do you know my posts about the SDK?
You can edit the sdk java files and also switch from cropped to full lepton resolution. Read this thread for more informations...
I think you are the only one, who testing the Flir SDK.
Here you can download a working SDK sample with the extracted java.class (see my post above)
 see path FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir\flironesdk\usb

have fun
http://www.file-upload.net/download-11040066/FLIROneSDKBundle04-Basis.zip.html

background:
 http://stackoverflow.com/questions/21417419/how-to-convert-aar-to-jar
Quote
Android Studio (version: 1.3.2) allows you to seamlessly access the .jar inside a .aar.
Bonus: it automatically decompiles the classes!
Simply follow these steps:
1. File > New > New Module > Import .JAR/.AAR Package to import you .aar as a module
2. Add the newly created module as a dependency to your main project (not sure if needed)
3. Right click on "classes.jar" as shown in the capture below, and click "Show in explorer". Here is your .jar.

next step:
Android Studio / File / Project Structur
     Modules "app" / Dependencies / + "Module Dependency" and select FlirSDK




SDK without cropped images (full resolution 160x120):

change SDK path for CameraFiles from intern
/data/data/com.flir.flironeexampleapplication/files/CameraFiles
to extern
/sdcard/Android/data/com.flir.flironeexampleapplication/files/CameraFiles

by editing two code lines
Code: [Select]
\FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir>grep -r -n -A1  getFilesDir *
flironesdk/Device.java:213:        //FrameProcessor.updateCameraFiles(zis, cachedContext.getFilesDir().getAbsolutePath() + File.separator);
flironesdk/Device.java-214-        FrameProcessor.updateCameraFiles(zis, cachedContext.getExternalFilesDir(null).getAbsolutePath() + File.separator);
--
flironesdk/FrameProcessor.java:101:        // String storagePath = context.getFilesDir().getAbsolutePath() + File.separator;
flironesdk/FrameProcessor.java-102-        String storagePath = context.getExternalFilesDir(null).getAbsolutePath() + File.separator;

next step is avoid overwriting your file calib.rsc after starting the apk
edit the function updateCameraFiles() in file FrameProcessor.java
Code: [Select]
static void updateCameraFiles(ZipInputStream zis, String storagePath)
{
    try
    {
        ZipEntry ze;
        while ((ze = zis.getNextEntry()) != null) {
            File f = new File(storagePath + ze.getName());
            if ((!f.exists())||(!ze.getName().endsWith( "calib.rsc")))
            {
                if (ze.isDirectory()) {
                    //File f = new File(storagePath + ze.getName());
                    if (!f.isDirectory()) {
                        f.mkdirs();
                    }
                } else {
                    File parentDir = new File(storagePath + ze.getName()).getParentFile();
                    if (( null != parentDir) &&
                            (!parentDir.isDirectory())) {
                        parentDir.mkdirs();
                    }
                    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(storagePath + ze.getName()));
                    byte[] bytesIn = new byte['?' ];
                    int read;
                    while ((read = zis.read(bytesIn)) != - 1) {
                        bos.write(bytesIn, 0, read);
                    }
                    zis.closeEntry();
                    bos.flush();
                    bos.close();
                }
            }
        }
        zis.close();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
simple delete
/sdcard/Android/data/com.flir.flironeexampleapplication/files/CameraFiles/system/calib.rsc
for getting a fresh version of the file from the FlirOne Flash

now you can edit your calib.rsc (without always overwriting with original file from your F1)

edit your calib.rsc to remove the crop factor by removing the .calib.lensCorr part
the crop factor is inside *.fff files, this files are not bad pixel map files (like Ex):
Code: [Select]
.calib.lensCorr entry
.calib.lensCorr.ds_we_ap_fi_le index
.calib.lensCorr.ds_we_ap_fi_le.enabled bool true
.calib.lensCorr.ds_we_ap_fi_le.fileName text "ds_we_ap_fi_le_LCFMap.fff"
.calib.lensCorr.ds_we_ap_fi_le.rotation double 0.345
.calib.lensCorr.ds_we_ap_fi_le.type int32 100
.calib.lensCorr.ds_we_ap_fi_le.zoom double 7.69
.calib.lensCorr.ds_we_ap_fi_leExFOL2 index
.calib.lensCorr.ds_we_ap_fi_leExFOL2.enabled bool true
.calib.lensCorr.ds_we_ap_fi_leExFOL2.fileName text "ds_we_ap_fi_leExFOL2_LCFMap.fff"
.calib.lensCorr.ds_we_ap_fi_leExFOL2.rotation double 0.345
.calib.lensCorr.ds_we_ap_fi_leExFOL2.type int32 100
.calib.lensCorr.ds_we_ap_fi_leExFOL2.zoom double 7.69

calc a new checksum crc
Code: [Select]
// crc32 sample on bash command line

// count lines
$ wc -l calib.rsc
     646 calib.rsc

//print last line
$ tail -n1 calib.rsc
# CRC32 4683a151

//calc a new crc32 for (n-1) lines
$ crc32 <(head -n 645 calib.rsc)
4683a151
first try this steps with an original file
inside the large E4 thread in this forum you find some more methods for calculating the Flir CRC



a hint: the FlirOne App from Play Store save the original CameraFiles also to the visible path:
/sdcard/Android/data/com.flir.flirone/files/
CameraFiles.zip
CameraFilesSimu.zip

Here you can always get an original (unpatched) CameraFiles.zip.


view my thermal gallery  ;)
https://www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown/msg802245/#msg802245
Flir One G2 Lepton 160x120 with hacked config file calib.rsc


« Last Edit: December 13, 2015, 11:44:12 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #78 on: December 13, 2015, 11:37:37 am »
Hi sonic,

I saw in your code, that you modified the function onFrameProcessed().

Here is my code modification for onFrameProcessed() for saving full size raw images to *.raw

Another quick n' dirty solution works fine:

Save the ThermalLinearFlux14BitImage RAW image:

FLIRONEExampleApplication/app/src/main/java/com/flir/flironeexampleapplication/PreviewActivity.java
Code: [Select]

// for raw images
import java.io.FileOutputStream;

   public void onFrameProcessed(final RenderedImage renderedImage){
        thermalBitmap = renderedImage.getBitmap();
        updateThermalImageView(thermalBitmap);


        /*
        Capture this image if requested.
        */
        if (this.imageCaptureRequested) {
            imageCaptureRequested = false;
            final Context context = this;
            new Thread(new Runnable() {
                public void run() {
                    String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ssZ", Locale.getDefault());
                    String formatedDate = sdf.format(new Date());
                    String fileName = "FLIROne-" + formatedDate + ".jpg";
                    try{
                        lastSavedPath = path+ "/" + fileName;
                        renderedImage.getFrame().save(new File(lastSavedPath), RenderedImage.Palette.Iron, RenderedImage.ImageType.BlendedMSXRGBA8888Image);

                        MediaScannerConnection.scanFile(context,
                                new String[]{path + "/" + fileName}, null,
                                new MediaScannerConnection.OnScanCompletedListener() {
                                    @Override
                                    public void onScanCompleted(String path, Uri uri) {
                                        Log.i("ExternalStorage", "Scanned " + path + ":");
                                        Log.i("ExternalStorage", "-> uri=" + uri);
                                    }

                                });
                        if (renderedImage.imageType() == RenderedImage.ImageType.ThermalLinearFlux14BitImage){
                            // save the Lepton RAW file
                            String rawName = "FLIROne-" + formatedDate + ".raw";
                            lastSavedPath = path+ "/" + rawName;
                            File file = new File(lastSavedPath);
                            FileOutputStream fop = null;
                            fop = new FileOutputStream(file);
                            if (!file.exists()) {
                                file.createNewFile();
                            }
                            //int rawLength = renderedImage.pixelData().length;
                            byte[] LeptonRAWBytes = renderedImage.pixelData();
                            fop.write(LeptonRAWBytes);
                            fop.flush();
                            fop.close();
                        }

                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            thermalImageView.animate().setDuration(50).scaleY(0).withEndAction((new Runnable() {
                                public void run() {
                                    thermalImageView.animate().setDuration(50).scaleY(1);
                                }
                            }));
                        }
                    });
                }
            }).start();
        }
...


If the image type is set to "ThermalLinearFlux14BitImage" then it save also the raw frame 160x120 to disk.

So I got the nice gallery photo from F1G2:
...

« Last Edit: December 13, 2015, 11:45:28 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #79 on: December 13, 2015, 12:02:57 pm »
Hi cynfab,

you are right.
On my Raspberry Pi this glitches rarely happens, but they appear.
See my log from the first 300 frames.
Code: [Select]
-rw-r--r-- 1 root root     28 2015-12-13 12:47:47.628956961 +0100 EP0x85#00221.bin
-rw-r--r-- 1 root root  38828 2015-12-13 12:47:47.838952429 +0100 EP0x85#00222.bin
-rw-r--r-- 1 root root  63830 2015-12-13 12:47:48.048947898 +0100 EP0x85#00223.bin
there are also jumbo frames :)
Code: [Select]
-rw-r--r-- 1 root root 206830 2015-12-13 12:47:44.959014674 +0100 EP0x85#00207.bin
We know, that the USB Buffer size is limited to 512 Bytes (see lsusb -v and USB specification) .
The libusb driver glues the packets together to a "frame".
Quote
# lsusb -v -d 09cb:1996
...
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN           // libusb_bulk_transfer()
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
          wMaxPacketSize     0x0200  1x 512 bytes

I think, its simple to handle this different frame size in software.
One possibly is to stitch the packets self to a full frame (thermal+jpg+status)

Please look also at the full time stamp. Do you have another frame rate??
and sometimes the EP 85 reads come a lot faster than other times.

another minor information:
Now we know, that the header is not 32, but 28 Bytes and the raw image begins with the two status lines (2 Pixel * 16 Bit = 4 Byte).
With a 32 Byte header the status lines are in the middle and on the right side of the image.
Code: [Select]
-rw-r--r-- 1 kenm kenm     28 Dec 12 09:11 EP0x85#00029.bin
-rw-r--r-- 1 kenm kenm  39852 Dec 12 09:11 EP0x85#00030.bin


Until yet I not thought deeper about this 4 columns.

Encryptededdy linked this, but I think our columns (120px) are not telemetry datas (lines with 160 px) :

More info about the 4 lines of addtl' information: http://media.wix.com/ugd/53cdb6_5191be73d1c943d78d2e1a095cb7f3b8.pdf


« Last Edit: December 13, 2015, 07:56:46 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #80 on: December 13, 2015, 01:07:31 pm »
Hi cynfab,

Code: [Select]
-rw-r--r-- 1 root root    167 2015-12-13 12:47:54.798802942 +0100 EP0x85#00254.bin
-rw-r--r-- 1 root root  39340 2015-12-13 12:47:55.008798450 +0100 EP0x85#00255.bin
-rw-r--r-- 1 root root  70983 2015-12-13 12:47:55.228793750 +0100 EP0x85#00256.bin
after looking inside the glitch frames I get this result:
1. All packets with size about 60k are correct jpeg images without errors (begins with magic byte sequence of jpeg "FF 08 FF C0").
2. All packets with size about 40k are broken raw images, which misses the first/second line
3. All packets with size of 168 Bytes are correct status strings
4. All packets with size of 28 Bytes are the header bytes of a regular full frame (thermal+jpg+status)



my interpretation:
The FlirOne has an internal (timing/sync) problem with the i2c bus to lepton sensor.
This results sometimes in loosing the first lines of thermal sensor and as a result of this we get the usb glitches.
-> litter this frames (my waste quote is 10/314 frames = 3%)

my jumbo frames (200k) are two regular frames (thermal+jpg+status) without the second status, which follows behind with 169 Byte
Code: [Select]
-rw-r--r-- 1 root root 103719 2015-12-13 12:47:46.988970775 +0100 EP0x85#00218.bin
-rw-r--r-- 1 root root 206879 2015-12-13 12:47:47.218965810 +0100 EP0x85#00219.bin
-rw-r--r-- 1 root root    167 2015-12-13 12:47:47.418961494 +0100 EP0x85#00220.bin



for another readers:
currently Flir doesn't public infos about the Leptons radiometric feature:
http://www.flir.com/cvs/cores/knowledgebase/index.cfm?CFTREEITEMKEY=914&view=67485
the FlirOne is currently the only chance to get radiometric datas from Lepton 3 sensor (with black body calibration, thanks to Flir!!) ;)
« Last Edit: December 13, 2015, 01:28:12 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #81 on: December 14, 2015, 05:06:36 pm »
Hi tomas123,
All interesting stuff.
I think we need to look carefully at how the FlirOne SDK example and the decompiled SDK files work. As well as considering the use of libusb's Async API.
I should have some time this week to dig into things.
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #82 on: December 14, 2015, 10:53:06 pm »
I've figured out most of what the 28byte header is about:

A typical 28 byte header:

ef be 00 00 01 00 00 00 b3 02 02 00 ac 9b 00 00  <<< oops typo in orig post
60 66 01 00 a7 00 00 00 cf 4f 12 3c 00 30 ef 9e

From EPx85#00035.bin which is the combined thermal & jpeg.

ls -la
-rw-r--r-- 1 kenm kenm  91911 Dec 14 14:25 1.jpg
-rw-r--r-- 1 kenm kenm 131791 Dec 14 12:32 EP0x85#00035.bin

dd if=EP0x85#00035.bin of=1.jpg bs=1 skip=39880
91911+0 records in
91911+0 records out
91911 bytes (92 kB) copied, 0.140179 s, 656 kB/s

identify 1.jpg
1.jpg JPEG 640x480 640x480+0+0 8-bit DirectClass 91.9KB 0.000u 0:00.000

This jpeg has no EXIF data.

location of status start
28 + thermal image length + length of jpeg:
28 + 39852 + 91744 = 131624

dd if=EP0x85#00035.bin of=1.txt bs=1 skip=131624
167+0 records in
167+0 records out
167 bytes (167 B) copied, 0.000448197 s, 373 kB/s

cat 1.txt
{"shutterState":"FFC","shutterTemperature":307.850006103516,"usbNotifiedTimestamp":1176851589.8668,"usbEnqueuedTimestamp":1176851589.86892,"ffcState":"FFC_VALID_RAD"}

shutter states are FFC | ON
ffc states are Valid | Desired
(maybe more)

Byte Fields:

0 ef
1 be
2 00
3 00
4 01
5 00
6 00
7 00
8-b file (less 28 byte header) length: 02 02 b3 = 131763 + 28 = 131791
c-f length of thermal image:  9b ac = 39852 + 28 byte header = 39880
10-14 length of jpeg image: 01 66 60 = 91744 -> 91911 - 91744 = 167
14-17 length of status: a7 = 167
18-1b ??  still need to figure out what this is
1c-1d 00|10|20|30|40|50|60|70|80 ?? still need this
1e-1f checksum ?? this too.

   ...ken...

« Last Edit: December 15, 2015, 02:16:59 pm by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #83 on: December 15, 2015, 07:27:45 am »
Wow!!
I also looked inside the header but overlooked  thermal/jpg image size
Quote
c-f length of thermal image:  9b ac = 39852 + 28 byte header = 39880

for comparing as attachment 300 headers from my log
I filtered my glitches with "-size +90k", but sometimes (after a glitch) slips the status string to the header of the next "full frame"

The combination of image size >90k and magic bytes "ef be"  is the best marker.

Code: [Select]
$ for i in $(find . -type f -name "EP0x85*" -size +90k); do  ls -al $i; hexdump -C -n 32 $i;done
-rw-r--r--@ 1 tom  staff  101476 13 Dez 12:47 ./EP0x85#00006.bin
00000000  ef be 00 00 01 00 00 00  48 8c 01 00 ac 9b 00 00  |........H.......|
00000010  00 f0 00 00 9c 00 00 00  32 b8 42 8a 00 40 6e 6f  |........2.B..@no|
00000020
-rw-r--r--@ 1 tom  staff  101516 13 Dez 12:47 ./EP0x85#00007.bin
00000000  ef be 00 00 01 00 00 00  70 8c 01 00 ac 9b 00 00  |........p.......|
00000010  28 f0 00 00 9c 00 00 00  7d 1b da 22 00 50 a3 d0  |(.......}..".P..|
00000020
-rw-r--r--@ 1 tom  staff  101430 13 Dez 12:47 ./EP0x85#00008.bin
00000000  ef be 00 00 01 00 00 00  1a 8c 01 00 ac 9b 00 00  |................|
00000010  d0 ef 00 00 9e 00 00 00  85 07 39 f8 00 50 3e 6b  |..........9..P>k|
00000020
-rw-r--r--@ 1 tom  staff  101336 13 Dez 12:47 ./EP0x85#00009.bin
00000000  ef be 00 00 01 00 00 00  64 8c 01 00 ac 9b 00 00  |........d.......|
00000010  10 f0 00 00 a8 00 00 00  5a 4e ad 39 00 50 b4 c5  |........ZN.9.P..|
00000020
-rw-r--r--@ 1 tom  staff  101488 13 Dez 12:47 ./EP0x85#00011.bin
00000000  ef be 00 00 01 00 00 00  fc 8c 01 00 ac 9b 00 00  |................|
00000010  a8 f0 00 00 a8 00 00 00  6d cf 77 f5 00 70 d5 1e  |........m.w..p..|
00000020
-rw-r--r--@ 1 tom  staff  101719 13 Dez 12:47 ./EP0x85#00012.bin
00000000  7b 22 73 68 75 74 74 65  72 53 74 61 74 65 22 3a  |{"shutterState":|
00000010  22 46 46 43 22 2c 22 73  68 75 74 74 65 72 54 65  |"FFC","shutterTe|
00000020
-rw-r--r--@ 1 tom  staff  101647 13 Dez 12:47 ./EP0x85#00013.bin
00000000  ef be 00 00 01 00 00 00  f3 8c 01 00 ac 9b 00 00  |................|
00000010  a0 f0 00 00 a7 00 00 00  b4 a3 1b f0 00 30 20 d3  |.............0 .|
00000020
-rw-r--r--@ 1 tom  staff  141638 13 Dez 12:47 ./EP0x85#00014.bin
00000000  ef be 00 00 01 00 00 00  62 8d 01 00 ac 9b 00 00  |........b.......|
00000010  10 f1 00 00 a6 00 00 00  d1 80 6f 95 00 60 b7 0b  |..........o..`..|
00000020
-rw-r--r--@ 1 tom  staff  101847 13 Dez 12:47 ./EP0x85#00016.bin
00000000  ef be 00 00 01 00 00 00  bb 8d 01 00 ac 9b 00 00  |................|
00000010  68 f1 00 00 a7 00 00 00  df 46 b9 1b 00 50 dc 5b  |h........F...P.[|
00000020
-rw-r--r--@ 1 tom  staff  101861 13 Dez 12:47 ./EP0x85#00017.bin
00000000  ef be 00 00 01 00 00 00  c9 8d 01 00 ac 9b 00 00  |................|
00000010  78 f1 00 00 a5 00 00 00  05 29 cd 95 00 30 33 4c  |x........)...03L|
00000020
-rw-r--r--@ 1 tom  staff  101783 13 Dez 12:47 ./EP0x85#00018.bin
00000000  ef be 00 00 01 00 00 00  7b 8d 01 00 ac 9b 00 00  |........{.......|
00000010  28 f1 00 00 a7 00 00 00  3c 9f a7 40 00 40 cc ad  |(.......<..@.@..|
00000020
-rw-r--r--@ 1 tom  staff  101631 13 Dez 12:47 ./EP0x85#00019.bin
00000000  ef be 00 00 01 00 00 00  e3 8c 01 00 ac 9b 00 00  |................|
00000010  90 f0 00 00 a7 00 00 00  57 ce f1 93 00 50 8b 4c  |........W....P.L|
00000020
-rw-r--r--@ 1 tom  staff  101839 13 Dez 12:47 ./EP0x85#00020.bin
00000000  ef be 00 00 01 00 00 00  b3 8d 01 00 ac 9b 00 00  |................|
00000010  60 f1 00 00 a7 00 00 00  25 c2 4f bb 00 60 59 53  |`.......%.O..`YS|
00000020
-rw-r--r--@ 1 tom  staff  101871 13 Dez 12:47 ./EP0x85#00021.bin
00000000  ef be 00 00 01 00 00 00  d3 8d 01 00 ac 9b 00 00  |................|
00000010  80 f1 00 00 a7 00 00 00  c3 6a de 01 00 20 59 89  |.........j... Y.|
00000020
-rw-r--r--@ 1 tom  staff  100807 13 Dez 12:47 ./EP0x85#00022.bin
00000000  ef be 00 00 01 00 00 00  ab 89 01 00 ac 9b 00 00  |................|
00000010  58 ed 00 00 a7 00 00 00  e5 b8 51 52 00 40 66 41  |X.........QR.@fA|
00000020
-rw-r--r--@ 1 tom  staff  100775 13 Dez 12:47 ./EP0x85#00023.bin
00000000  ef be 00 00 01 00 00 00  8b 89 01 00 ac 9b 00 00  |................|
00000010  38 ed 00 00 a7 00 00 00  23 63 85 95 00 50 56 d3  |8.......#c...PV.|
00000020

« Last Edit: December 15, 2015, 02:36:38 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #84 on: December 15, 2015, 03:51:47 pm »
Hi cynfab,

your infos for endpoint 0x85 in formatted notation:


dump header

$ hexdump -C -n 32 ./EP0x85#00019.bin
-rw-r--r--@ 1 tom  staff  101631 13 Dez 12:47 ./EP0x85#00019.bin
00000000  ef be 00 00 01 00 00 00  e3 8c 01 00 ac 9b 00 00  |................|
00000010  90 f0 00 00 a7 00 00 00  57 ce f1 93 00 50 8b 4c  |........W....P.L|

->  file size  101.631 Byte
    header         -28 Byte
    ---------------------
    frame size 101.603 Byte

--------------------------------------
header

address   
00000000  ef be 00 00   magic bytes 0xEF 0xBE
00000004  01 00 00 00   0x00000001
00000008  e3 8c 01 00   0x00018CE3 = 101.603 byte frame size

0000000C  ac 9b 00 00   0x00009BAC =  39.852 byte thermal image size
00000010  90 f0 00 00   0x0000F090 =  61.584 byte jpg image size
00000014  a7 00 00 00   0x000000A7 =     167 byte status string size
                                     ------------
                             total:  101.603 byte frame size
00000018  57 ce f1 93   unknown
0000001C  00 50 8b 4c   unknown

--------------------------------------------
start adresses

size       adress   (in dezimal)
           0000000  magic bytes 0xEF 0xBE
+     28   0000028  thermal image with size of 39.852 byte
+ 39.852   0039880  jpg image with size of 61.584 byte
+ 61.584   0101464  status string with size of 167 byte
+    167
---------
 101.631 total file size




identify 1.jpg
1.jpg JPEG 640x480 640x480+0+0 8-bit DirectClass 91.9KB 0.000u 0:00.000

This jpeg has no EXIF data.

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #85 on: December 15, 2015, 04:11:09 pm »
Hi cynfab,

some infos:

my next step (on weekend) is to write a code for a V4L2 loopback devices ( /dev/video0 )
Then we can simple connect the FlirOne with Linux video world  ;)

3 month ago I supplemented the great code from user tmbinc  :-+ with a loopback "driver" for the Flir E4, therefore I can recycle most of the the code.
see: https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg756530/#msg756530

another thermal video concept with OpenCV comes from user Bud:
see my linklist: https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg729604/#msg729604

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #86 on: December 15, 2015, 05:05:02 pm »
Hi tomas123,

I was going to do a better job of documenting the EP 81 & EP 83 headers, but here are my raw notes:

Header for EP 81 data

16 bytes

cc 01 00 00 01 00 00 00 55 00 00 00 30 73 8c df


00-03 Header ID cc 01 00 00
04    01
05    00
06    00
06    00
08-0b 00 00 00 55 length of message
0c    ??
0d    ??
0e-0f checksum ??
10-end-1 status message
end   00

++++++++++++++++++++++++

header for the EP83 --> camerafiles.zip
24 bytes

10 55 00 00 01 00 00 00 b7 1a 00 00 0a 00 00 00
00 99 9d 5d 2c 91 a3 df

00-03 header ID 10 55 00 00
04    01
05    00
06    00
07    00
08-0b 00 00 1a b7 = 6839 length of CameraFiles.zip
0c
0d
0e
0f
10
11
12
13
14
15
16-17 checksum ??
18-end CameraFiles.zip


I'd like to see a v4l2 driver too, but I haven't the skills to create one from  scratch.
I'd also like to replicate my dual view android app, maybe as an offshoot of your v4l2 work.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #87 on: December 17, 2015, 12:17:23 am »
Hi cynfab,

I copied the framebuffer and v4l2 code parts from here
https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg756530/#msg756530
to our code.

This code is only a first buggy study!!

hardware: raspberry pi
$ uname -a
Linux raspberryLCD 3.18.13-v7+ #784 SMP PREEMPT Sat May 9 15:57:36 BST 2015 armv7l GNU/Linux



flir8a.c writes the thermal video stream only to the linux framebuffer.
You must switch from your x session to a virtual console (native shell) to see the framebuffer.
I wrote the code for my raspberry display 800x480 in 16 bit.
See comments in code for another resolution and bit depth.

compile with
Code: [Select]
$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0'  -o flir flir8a.c -lusb-1.0 -lm
Code: [Select]
$ sudo ./flir
The framebuffer device opened.
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

:xx Thu Dec 17 01:08:24 2015

: Thu Dec 17 01:08:24 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_TIMEOUT

: Thu Dec 17 01:08:25 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_TIMEOUT

ask for CameraFiles.zip on EP 0x83:

: Thu Dec 17 01:08:26 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Thu Dec 17 01:08:26 2015





flir8b.c writes the thermal video stream to the linux framebuffer and /dev/video0

read my notes to install v4l2loopback on a raspberry pi
https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg756530/#msg756530
and for a V4L2 loopback device under Ubuntu
https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg756831/#msg756831

don't forget to load the kernel driver:
Code: [Select]
$ sudo depmod -a  `uname -r`
$ sudo modprobe v4l2loopback

$ lsmod
Module                  Size  Used by
v4l2loopback           23348  0
videodev              122487  1 v4l2loopback

For v4l2 I removed the switch "std=c99" (avoid "/usr/include/linux/videodev2.h:2090:20: error: field ‘timestamp’ has incomplete type").
Compile with
Code: [Select]
$ /usr/bin/gcc '-I/usr/include/libusb-1.0'  -o flir flir8b.c -lusb-1.0 -lm

start with
Code: [Select]
$ sudo ./flir
The framebuffer device opened.
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
using output device: /dev/video0
     vid_format->type                =2
     vid_format->fmt.pix.width       =160
     vid_format->fmt.pix.height      =120
     vid_format->fmt.pix.pixelformat =1497715271
     vid_format->fmt.pix.sizeimage   =20480
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=160
     vid_format->fmt.pix.colorspace  =8
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

:xx Thu Dec 17 00:52:26 2015

: Thu Dec 17 00:52:26 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81: LIBUSB_ERROR_TIMEOUT

: Thu Dec 17 00:52:27 2015
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83: LIBUSB_ERROR_TIMEOUT

ask for CameraFiles.zip on EP 0x83:

: Thu Dec 17 00:52:28 2015

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Thu Dec 17 00:52:28 2015

: Thu Dec 17 00:52:28 2015
 bulk read EP 0x81, actual length 23
HEX:

STRING:
gMode":"operational"}}

Ask for video stream, start EP 0x85:

: Thu Dec 17 00:52:28 2015
 bulk read EP 0x81, actual length 108
HEX:

STRING:
?\?<??{"type":"openFileStatus","data":{"path":"CameraFiles.zip","streamIdentifier":9,"mode":"r"}}


use mplayer to get the stream
Code: [Select]
$ sudo mplayer tv:// -tv driver=v4l2:device=/dev/video0
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: Dummy video device (0x0000)
 Capabilities:  video capture  read/write  streaming
 supported norms:
 inputs: 0 = loopback;
 Current input: 0
 Current format: GREY
...
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
Movie-Aspect is undefined - no prescaling applied.
[swscaler @ 0x562380] using unscaled gray -> yuv420p special converter
VO: [sdl] 160x120 => 160x120 Planar YV12



PS: I have the suspicion that the delay of flir8a.c (frame buffer) is a little bit greater as in the Flir App in mode ThermalLinearFlux14BitImage :-\
« Last Edit: December 17, 2015, 08:17:29 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #88 on: December 17, 2015, 12:40:30 am »
Hi tomas123,
wow that was fast, looks very interesting, I'll be playing with that code over the next few days.
Nice job!!
   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #89 on: December 17, 2015, 12:43:27 am »
only cut and paste  8)

frame buffer works fine, but v4l2 needs some tuning...

the original frame buffer code comes from user tmbinc  :-+
watch his video: https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg626608/#msg626608
and get the code (another resolution): https://www.eevblog.com/forum/testgear/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg736344/#msg736344

please note the great font.h
« Last Edit: December 17, 2015, 12:52:43 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #90 on: December 17, 2015, 11:06:29 pm »
flir8b.c writes the thermal video stream to  /dev/video0 and works better than expected.
Runs since hours rock stable!

here my experiences with a live stream from raspberry pi to my notebook:

start Flir One video grabber on raspberry pi
Code: [Select]
$ sudo modprobe v4l2loopback
$ /usr/bin/gcc '-I/usr/include/libusb-1.0'  -o flir flir8b.c -lusb-1.0 -lm
$ sudo ./flir

start a video server on raspberry pi with avconv and stream /dev/video0 to my notebook with address 192.168.1.42
(parameters yet not adjusted)
Code: [Select]
$ avconv -f video4linux2 -i /dev/video0 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.1.42:1234
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
[video4linux2 @ 0x1ffc740] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 1450392797.097902, bitrate: 4608 kb/s
    Stream #0.0: Video: rawvideo, gray, 160x120, 4608 kb/s, 1000k tbn, 30 tbc
Output #0, rtp, to 'rtp://192.168.1.42:1234':
  Metadata:
    encoder         : Lavf54.20.4
    Stream #0.0: Video: mpeg2video, yuv420p, 160x120, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
...
Press ctrl-c to stop encoding
frame=23557 fps= 25 q=2.0 size=   14522kB time=942.20 bitrate= 126.3kbits/s   
 

on my notebook:
start VLC and open the stream with
   vlc / open network
Code: [Select]
rtp://@:1234and we get a live stream  8)





my first test with motion http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

our flir device:
Code: [Select]
$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Capture
Pixel Format: 'GREY'
Name        : [GREY]
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)

install motion
Code: [Select]
$ sudo apt-get install motion
edit config file
Code: [Select]
$ sudo nano /etc/motion/motion.conf

# Maximum framerate for webcam streams (default: 1)
webcam_maxrate 10

# Restrict webcam connections to localhost only (default: on)
webcam_localhost off

but we cant select our frame format V4L2_PIX_FMT_GREY in motion.conf  :(
Code: [Select]
# v4l2_palette allows to choose preferable palette to be use by motion
# V4L2_PIX_FMT_SN9C10X : 0  'S910'
# V4L2_PIX_FMT_SBGGR8  : 1  'BA81'
# V4L2_PIX_FMT_MJPEG   : 2  'MJPEG'
# V4L2_PIX_FMT_JPEG    : 3  'JPEG'
# V4L2_PIX_FMT_RGB24   : 4  'RGB3'
# V4L2_PIX_FMT_UYVY    : 5  'UYVY'
# V4L2_PIX_FMT_YUYV    : 6  'YUYV'
# V4L2_PIX_FMT_YUV422P : 7  '422P'
# V4L2_PIX_FMT_YUV420  : 8  'YU12'
v4l2_palette 8

It's possible to convert /dev/video0 with ffmpeg to a compatible frame format and write to next device /dev/video1.
But I think it's better to make the converts in our code (like the current convert for frame buffer to RGB565 16 Bit)   
« Last Edit: December 17, 2015, 11:47:06 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #91 on: December 18, 2015, 01:09:52 am »
tomas123,
I've run this with mplayer and it works as described, every so often I get a noise frame, but it seems to correct itself quickly.

Nice work. this will be the beginning of FlirOne for Linux (maybe MacOSX  and Windoze too)

  ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #92 on: December 18, 2015, 08:56:09 am »
...this will be the beginning of FlirOne for Linux (maybe MacOSX  and Windoze too)

I believe not.
Since last two years I wrote here hundreds of posts about
  • hacking Flir RAW formats (exiftool)
  • Plancks Law
  • calculate temperature from flir radiometric sensor values with Flir calibration values
  • stitch thermal panoramas
  • raw videos and streaming of Flir Ex, Flir Exx  and Flir One 2. gen
  • convert thermal images and videos from another manufacturers (Seek, Opgal) in Flir radiometric jpg / video and open it with Flir Tools for evaluation

... but only half a dozen users are interested in

I've run this with mplayer and it works as described, every so often I get a noise frame, but it seems to correct itself quickly.
Do you mean a FFC frame,  a regular 160x120 frame with a closed shutter ?
Otherwise flir8b.c is until missing a validation of frame size (make only a magic byte check), therefore we have sometimes noise glitches.
But I haven't seen v4l2 sync problems...

please post my a "ls -al" of 1 or 2 minutes EP0x85#00xxx.bin, so I can see how often your system got broken frames
« Last Edit: December 18, 2015, 10:36:35 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #93 on: December 19, 2015, 01:03:27 pm »
Hi cynfab,

I found this nice short source samples on github with lepton drivers on the basis of https://github.com/umlaeute/v4l2loopback :
https://github.com/andrewhodel/flirpi-mjpeg
Quote
"These are miscellaneous utilities that work with the lepton module on the raspberry pi."
a fork of https://github.com/groupgets/LeptonModule/tree/master/software/flirpi

forum: https://groups.google.com/forum/#!topic/flir-lepton/VcdpMY_vcho

the code is for Lepton G1 80x60 connected over SPI
Quote
leptsci.c is the code to access the flir module over SCI and fill an image buffer.
and we fill our image buffer over usb




please post my a "ls -al" of 1 or 2 minutes EP0x85#00xxx.bin, so I can see how often your system got broken frames
;)
« Last Edit: December 19, 2015, 01:17:14 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #94 on: December 19, 2015, 02:01:46 pm »
Hi tomas123,
Looks interesting, I'm tied up all weekend and into next week, so I probably won't get to do anything with the FlirOne till Xmas.

   ...ken...
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #95 on: December 20, 2015, 07:31:11 pm »
Hi tomas123,
I got some some time to fiddle with the flir code and here is a "simplified" version that works pretty well.
With Guvcview it gets almost to 9fps on my i7 linux Mint 17.3 desktop.


   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #96 on: December 20, 2015, 10:29:41 pm »
With Guvcview it gets almost to 9fps on my i7 linux Mint 17.3 desktop.

sorry, my mistake...
Code: [Select]
r = libusb_bulk_transfer(devh, 0x83, buf, sizeof(buf), &actual_length, 100); ...because the "old" code polls permanently the empty EP 0x81 and 0x83 with a timeout of 100ms, therefore we got only a max frame rate of 1000/(2*100)=5 fps

if we set in the old code flir7i.c (write frames to file) the timeout of EP 0x85 to 10ms we get to 9 fps

this is one second and I count 9 thermal frames

$ /usr/bin/gcc -std=c99 '-I/usr/include/libusb-1.0'  -o flir flir7i.c -lusb-1.0 -lm
$ sudo ./flir
...
$ ls -al --time-style=full-iso *0x85*
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.054600840 +0100 #00551-EP0x85.bin
-rw-r--r-- 1 root root  38828 2015-12-20 23:20:34.084600631 +0100 #00552-EP0x85.bin
-rw-r--r-- 1 root root  73008 2015-12-20 23:20:34.114600423 +0100 #00553-EP0x85.bin
-rw-r--r-- 1 root root    167 2015-12-20 23:20:34.144600214 +0100 #00554-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.164600075 +0100 #00555-EP0x85.bin
-rw-r--r-- 1 root root  38828 2015-12-20 23:20:34.194599866 +0100 #00556-EP0x85.bin
-rw-r--r-- 1 root root  73079 2015-12-20 23:20:34.224599657 +0100 #00557-EP0x85.bin
-rw-r--r-- 1 root root  39880 2015-12-20 23:20:34.294599171 +0100 #00558-EP0x85.bin
-rw-r--r-- 1 root root  73415 2015-12-20 23:20:34.324598962 +0100 #00559-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.384598544 +0100 #00560-EP0x85.bin
-rw-r--r-- 1 root root  38828 2015-12-20 23:20:34.414598336 +0100 #00561-EP0x85.bin
-rw-r--r-- 1 root root  73175 2015-12-20 23:20:34.444598127 +0100 #00562-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.514597640 +0100 #00563-EP0x85.bin
-rw-r--r-- 1 root root  38828 2015-12-20 23:20:34.544597432 +0100 #00564-EP0x85.bin
-rw-r--r-- 1 root root  73647 2015-12-20 23:20:34.574597223 +0100 #00565-EP0x85.bin
-rw-r--r-- 1 root root 112768 2015-12-20 23:20:34.644596736 +0100 #00566-EP0x85.bin
-rw-r--r-- 1 root root    167 2015-12-20 23:20:34.664596597 +0100 #00567-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.734596110 +0100 #00568-EP0x85.bin
-rw-r--r-- 1 root root  39852 2015-12-20 23:20:34.764595901 +0100 #00569-EP0x85.bin
-rw-r--r-- 1 root root  73048 2015-12-20 23:20:34.794595693 +0100 #00570-EP0x85.bin
-rw-r--r-- 1 root root    167 2015-12-20 23:20:34.814595553 +0100 #00571-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.844595345 +0100 #00572-EP0x85.bin
-rw-r--r-- 1 root root  39852 2015-12-20 23:20:34.874595136 +0100 #00573-EP0x85.bin
-rw-r--r-- 1 root root  73575 2015-12-20 23:20:34.904594927 +0100 #00574-EP0x85.bin
-rw-r--r-- 1 root root     28 2015-12-20 23:20:34.964594510 +0100 #00575-EP0x85.bin
-rw-r--r-- 1 root root  38828 2015-12-20 23:20:34.994594301 +0100 #00576-EP0x85.bin

it's interesting , with 10ms timeout we get no jumbo frames (header+thermal+visible+status) but rather splittet frames

My next step is to write a pipe and stitch the splittet frames together to a full frame...
« Last Edit: December 20, 2015, 10:35:46 pm by tomas123 »
 

Offline Lord of nothing

  • Super Contributor
  • ***
  • Posts: 1271
  • Country: at
Re: Question about FLIR One for Android
« Reply #97 on: December 22, 2015, 12:03:09 am »
Its possible to search for Animals in the Woods with the Cam?
I know the resolution is very low.  :-+
Made in Japan, destroyed in Sulz im Wienerwald.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #98 on: December 22, 2015, 11:19:07 pm »
@Lord of nothing
I think, this thread is better qualified for your question:
https://www.eevblog.com/forum/testgear/actual-resolution-of-flir-one-v2/


@cynfab

I saw, that you removed the frame buffer part.
As attachment my last "Flir to v4l2loopback" version without a framebuffer.

compile:
Code: [Select]
$ /usr/bin/gcc '-I/usr/include/libusb-1.0'  -o flir flir8f.c -lusb-1.0 -lm
$ sudo ./flir
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
using output device: /dev/video0
     vid_format->type                =2
     vid_format->fmt.pix.width       =160
     vid_format->fmt.pix.height      =120
     vid_format->fmt.pix.pixelformat =1497715271
     vid_format->fmt.pix.sizeimage   =19200
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=160
     vid_format->fmt.pix.colorspace  =8
using output device: /dev/video1
     vid_format->type                =2
     vid_format->fmt.pix.width       =640
     vid_format->fmt.pix.height      =480
     vid_format->fmt.pix.pixelformat =1196444237
     vid_format->fmt.pix.sizeimage   =1228800
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=0
     vid_format->fmt.pix.colorspace  =8
stop interface 2 FRAME
stop interface 1 FILEIO
start interface 1 FILEIO
...

new feature:
- add chunks from EP0x85 to a full frame (thermal+jpg+status)
- calc addresses inside "full frame" with infos from your reversed engineered header
- write thermal images to /dev/video0 as grayscale video 160x120
- write visible images to /dev/video1 as mjpeg video 640x480

please note, you must load v4l2loopback with /dev/video0 and /dev/video1
Code: [Select]
// unload v4l2loopback
$ sudo modprobe -r v4l2loopback

$ ls /dev/video*
ls: cannot access /dev/video*: No such file or directory

$ sudo modprobe v4l2loopback video_nr=0,1

$ ls /dev/video*
/dev/video0  /dev/video1

now you can view thermal and visible video simultaneously (i.e. with your guvcview in two windows)

I haven't changed the initialization sequence for the end points, because it's the same like in the SDK. I think, it's the safest way for future firmwares etc.

Your advice on the correlation between "sum of time outs" and "frame rate" was great   :-+
I played around with some time outs and found this as the best solution for my raspberry pi:
Code: [Select]
r = libusb_bulk_transfer(devh, 0x85, buf, sizeof(buf), &actual_length, 100);
...
r = libusb_bulk_transfer(devh, 0x81, buf, sizeof(buf), &actual_length, 10);
r = libusb_bulk_transfer(devh, 0x83, buf, sizeof(buf), &actual_length, 10);
EP 0x81 and 0x83 are almost empty (time out of 10ms works fine) and EP 0x85 lose regularly some bytes between chunks, if the time out is shorter as 100ms.

For debugging the code prints the status messages from EPx85.
On the basis of usbNotifiedTimestamp we get the frame rate of 9fps.
As sample a part of the terminal log with a FCC (shutter movement).
Code: [Select]
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.02701,"usbEnqueuedTimestamp":1175531262.02879,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.14032,"usbEnqueuedTimestamp":1175531262.14213,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.25351,"usbEnqueuedTimestamp":1175531262.25556,"ffcState":"FFC_VALID_IMG"}
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.36882,"usbEnqueuedTimestamp":1175531262.37076,"ffcState":"FFC_VALID_IMG"}
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.48126,"usbEnqueuedTimestamp":1175531262.48321,"ffcState":"FFC_VALID_IMG"}
{"shutterState":"ON","shutterTemperature":312.040008544922,"usbNotifiedTimestamp":1175531262.70933,"usbEnqueuedTimestamp":1175531262.7114,"ffcState":"FFC_DESIRED"}
{"shutterState":"ON","shutterTemperature":311.970001220703,"usbNotifiedTimestamp":1175531262.82371,"usbEnqueuedTimestamp":1175531262.8254,"ffcState":"FFC_PROGRESS"}
{"shutterState":"ON","shutterTemperature":311.970001220703,"usbNotifiedTimestamp":1175531262.93882,"usbEnqueuedTimestamp":1175531262.94059,"ffcState":"FFC_PROGRESS"}
{"shutterState":"ON","shutterTemperature":311.970001220703,"usbNotifiedTimestamp":1175531263.05156,"usbEnqueuedTimestamp":1175531263.0532,"ffcState":"FFC_PROGRESS"}
{"shutterState":"FFC","shutterTemperature":311.970001220703,"usbNotifiedTimestamp":1175531263.16526,"usbEnqueuedTimestamp":1175531263.16728,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"FFC","shutterTemperature":311.970001220703,"usbNotifiedTimestamp":1175531263.2799,"usbEnqueuedTimestamp":1175531263.28168,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"FFC","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531263.39377,"usbEnqueuedTimestamp":1175531263.39579,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"FFC","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531263.96461,"usbEnqueuedTimestamp":1175531263.96619,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"FFC","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.07757,"usbEnqueuedTimestamp":1175531264.07966,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"FFC","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.19097,"usbEnqueuedTimestamp":1175531264.19271,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.30465,"usbEnqueuedTimestamp":1175531264.30635,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.41937,"usbEnqueuedTimestamp":1175531264.42115,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.5326,"usbEnqueuedTimestamp":1175531264.53417,"ffcState":"FFC_VALID_RAD"}
{"shutterState":"ON","shutterTemperature":311.959991455078,"usbNotifiedTimestamp":1175531264.64702,"usbEnqueuedTimestamp":1175531264.64891,"ffcState":"FFC_VALID_RAD"}
Note the difference between shutterState  and ffcStat!
« Last Edit: December 22, 2015, 11:59:10 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #99 on: December 23, 2015, 01:58:17 am »
Hi tomas123,
Yep, I removed the framebuffer code. That's because my current target is to stream the thermal and visible images from a headless embedded processor.
Here is a video I captured with Guvcview. Encoding is MPEG 1 so the pixels are a bit fuzzy.

Just remove the .txt and play it with totem on Linux.

I'll try our your new code asap.....Maybe tomorrow... lots of snow here, need to plow the driveway again... and again... and again........

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #100 on: December 26, 2015, 07:55:15 pm »
I saw, there is a typo in line 245 of file flir8f.c.

changed
Code: [Select]
   write(fdwr1, &buf[28+ThermalSize], JpgSize);to
Code: [Select]
   write(fdwr1, &buf85[28+ThermalSize], JpgSize);

edit
... and a memory leak  >:(
Code: [Select]
  // write video to v4l2loopback
   write(fdwr0, fb_proc, framesize0);
   write(fdwr1, &buf85[28+ThermalSize], JpgSize);
   
   free(fb_proc);
« Last Edit: December 28, 2015, 11:11:16 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #101 on: December 29, 2015, 01:41:37 am »
Hi tomas123,
This looks really good, better than my last effort that just hoped to get a full frame.
Have you had any luck getting video1 to stream the visual jpg data?
I've poked at it and still have no clue as to what it should do. The v4l2 api is very dense reading. :( and I am struggling with trying to understand what I need to do.
But, it looks like things are progressing.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #102 on: December 29, 2015, 04:43:54 pm »
Have you had any luck getting video1 to stream the visual jpg data?

Yes, my last code (found typo buff85 and the memory leak) runs since two days without errors on /dev/video0 and /dev/video1 on my raspberry pi.

after 1.309.405 frames with 8,2 fps:
(1.309.405/8,2/3600=44 hours)

Code: [Select]
#1309405 82/10 fps:{"shutterState":"ON","shutterTemperature":311.869995117188,"usbNotifiedTimestamp":1176080489.24421,"usbEnqueuedTimestamp":1176080489.24568,"ffcState":"FFC_VALID_RAD"}
#1309406 83/10 fps:{"shutterState":"ON","shutterTemperature":311.869995117188,"usbNotifiedTimestamp":1176080489.35792,"usbEnqueuedTimestamp":1176080489.35936,"ffcState":"FFC_VALID_RAD"}
#1309407 82/10 fps:{"shutterState":"ON","shutterTemperature":311.880004882812,"usbNotifiedTimestamp":1176080489.4717,"usbEnqueuedTimestamp":1176080489.47328,"ffcState":"FFC_VALID_RAD"}
#1309408 82/10 fps:{"shutterState":"ON","shutterTemperature":311.880004882812,"usbNotifiedTimestamp":1176080489.5864,"usbEnqueuedTimestamp":1176080489.58808,"ffcState":"FFC_VALID_RAD"}
#1309409 82/10 fps:{"shutterState":"ON","shutterTemperature":311.880004882812,"usbNotifiedTimestamp":1176080489.70209,"usbEnqueuedTimestamp":1176080489.70338,"ffcState":"FFC_VALID_RAD"}

With Guvcview I can view both videos simultaneously with perfect quality (no drops and artefacts etc).
Can you exact describe your problems with /dev/video1 ?

My next step is to send both video (thermal/real) with RTSP streaming (ffmpeg) to a Synology surveillance station ...


edit:

Do you remember, how many time I wasted on the wrong system (Linux VM, OS X)?
Apparently the FlirOne G2 USB connection is tricky...
 
I played around with some time outs and found this as the best solution for my raspberry pi:
Code: [Select]
r = libusb_bulk_transfer(devh, 0x85, buf, sizeof(buf), &actual_length, 100);
...
r = libusb_bulk_transfer(devh, 0x81, buf, sizeof(buf), &actual_length, 10);
r = libusb_bulk_transfer(devh, 0x83, buf, sizeof(buf), &actual_length, 10);
EP 0x81 and 0x83 are almost empty (time out of 10ms works fine) and EP 0x85 lose regularly some bytes between chunks, if the time out is shorter as 100ms.

if you see in the terminal this correct status string, then you know, that all chunks are correct stitched to a full frame without loosing bytes
(the status string is the end of a full frame)
Code: [Select]
#1309405 82/10 fps:{"shutterState":"ON","shutterTemperature":311.869995117188,"usbNotifiedTimestamp":1176080489.24421,"usbEnqueuedTimestamp":1176080489.24568,"ffcState":"FFC_VALID_RAD"}
« Last Edit: December 29, 2015, 05:32:14 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #103 on: December 29, 2015, 05:35:10 pm »
Hi tomas123,
I start the videoloopback module like this:

sudo modprobe v4l2loopback exclusive_caps=0,0 video_nr=0,1

then run flir8g, then guvcview.
THis then displays the thermal image.
I then go to video controls and select device 1.
Guvcview then gives an error that it can't start a video stream on that device... see attached screenshot.

I can certainly believe that the F1G2 USB is odd as I have continuous problems on Android with various apps not being able to claim the usb interface.
I believe all the chunks are being stiched as the screenshot shows the terminal output.

   ...ken...
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #104 on: December 29, 2015, 06:13:21 pm »
And, this is what I get with mplayer...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #105 on: December 30, 2015, 12:06:15 am »
hm, my mplayer also works fine

after first 400 frames (ignore the warnings):
Code: [Select]
$ mplayer tv:// -tv driver=v4l2:device=/dev/video1
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: Dummy video device (0x0001)
 Capabilities:  video capture  read/write  streaming
 supported norms:
 inputs: 0 = loopback;
 Current input: 0
 Current format: MJPEG
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
v4l2: ioctl set format failed: Invalid argument
tv.c: norm_from_string(pal): Bogus norm parameter, setting default.
v4l2: ioctl enum norm failed: Inappropriate ioctl for device
Error: Cannot set norm!
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
v4l2: ioctl query control failed: Invalid argument
Xlib:  extension "XFree86-VidModeExtension" missing on display "localhost:10.0".
[VO_XV] It seems there is no Xvideo support for your video card available.
[VO_XV] Run 'xvinfo' to verify its Xv support and read
[VO_XV] DOCS/HTML/en/video.html#xv!
[VO_XV] See 'mplayer -vo help' for other (non-xv) video out drivers.
[VO_XV] Try -vo x11.
[gl] using extended formats. Use -vo gl:nomanyfmts if playback fails.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Audio: no sound
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
VO: [gl_nosw] 640x480 => 640x480 Planar 422P
V:   0.0 399/399 ??% ??% ??,?% 0 0


Your screenshot shows bugless "full frames", therefore our code works fine.
It's possible, that you have trouble with your v4l2 drivers.

Please post your output from this commands:
Code: [Select]
$ ls -al /dev/video*
$ v4l2-ctl --list-devices
$ v4l2-ctl --all -d /dev/video0
$ v4l2-ctl --all -d /dev/video1

compare with my result
Code: [Select]
pi@raspberryLCD ~ $ ls -al /dev/video*
crw-rw---T+ 1 root video 81, 0 Dec 27 13:12 /dev/video0
crw-rw---T+ 1 root video 81, 1 Dec 27 13:12 /dev/video1

pi@raspberryLCD ~ $ v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video0

Dummy video device (0x0001) (platform:v4l2loopback-001):
/dev/video1

pi@raspberryLCD ~ $ v4l2-ctl --all -d /dev/video0
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0000)
Bus info      : platform:v4l2loopback-000
Driver version: 3.18.13
Capabilities  : 0x85208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x05208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Video input : 0 (loopback: ok)
Format Video Capture:
Width/Height  : 160/120
Pixel Format  : 'GREY'
Field         : None
Bytes per Line: 160
Size Image    : 19200
Colorspace    : SRGB
Custom Info   : feedcafe
Format Video Output:
Width/Height  : 160/120
Pixel Format  : 'GREY'
Field         : None
Bytes per Line: 160
Size Image    : 19200
Colorspace    : SRGB
Custom Info   : feedcafe
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 30.000 (30/1)
Write buffers    : 8

User Controls

                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0

pi@raspberryLCD ~ $ v4l2-ctl --all -d /dev/video1
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0001)
Bus info      : platform:v4l2loopback-001
Driver version: 3.18.13
Capabilities  : 0x85208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x05208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Video input : 0 (loopback: ok)
Format Video Capture:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Format Video Output:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 30.000 (30/1)
Write buffers    : 8

User Controls

                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0
« Last Edit: December 30, 2015, 12:35:29 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #106 on: December 30, 2015, 12:31:48 am »
there are some interesting differences between our mplayer output lines

my mplayer:
Code: [Select]
Current format: MJPEG
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
...
VO: [gl_nosw] 640x480 => 640x480 Planar 422P

your mplayer shows another video format
Code: [Select]
Current format: BGR32
Opening video decoder: [raw] RAW uncompressed video
...
VO: [vdpau] 640x480 => 640x480 Planar YV12

maybe, there is a another video driver on your system
reboot, check it and try to write to another port (like video2) or change in our code video0<->video1


PS: another difference:
please note, you must load v4l2loopback with /dev/video0 and /dev/video1
Code: [Select]
// unload v4l2loopback
$ sudo modprobe -r v4l2loopback

$ ls /dev/video*
ls: cannot access /dev/video*: No such file or directory

$ sudo modprobe v4l2loopback video_nr=0,1

$ ls /dev/video*
/dev/video0  /dev/video1

Why do you needs the switch "exclusive_caps"?
I start the videoloopback module like this:

sudo modprobe v4l2loopback exclusive_caps=0,0 video_nr=0,1

https://github.com/umlaeute/v4l2loopback/blob/master/NEWS
Quote
v4l2loopback-0.7.0

  - experimental'exclusive_caps' mode that only reports CAPTURE/OUTPUT
    capabilities exclusively (support for Chromium/WebRTC)
see also https://github.com/umlaeute/v4l2loopback/issues/78
« Last Edit: December 30, 2015, 12:50:17 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #107 on: December 30, 2015, 01:29:12 am »
Hi tomas123,

Well, there are quite a few differences between our v4l2loopback stuff.

Code: [Select]
kenm@kenm-Studio-XPS-8000 ~/FLIR_ONE/thomas123/New_test/v4l $ ls -al /dev/video*
crw-rw----+ 1 root video 81, 0 Dec 29 10:44 /dev/video0
crw-rw----+ 1 root video 81, 1 Dec 29 10:44 /dev/video1
kenm@kenm-Studio-XPS-8000 ~/FLIR_ONE/thomas123/New_test/v4l $ v4l2-ctl --list-devices
Dummy video device (0x0000) (v4l2loopback:0):
/dev/video0

Dummy video device (0x0001) (v4l2loopback:1):
/dev/video1

kenm@kenm-Studio-XPS-8000 ~/FLIR_ONE/thomas123/New_test/v4l $ v4l2-ctl --all -d /dev/video0
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0000)
Bus info      : v4l2loopback:0
Driver version: 0.8.0
Capabilities  : 0x05000002
Video Output
Read/Write
Streaming
Video output: 0 (loopback in)
Format Video Output:
Width/Height  : 160/120
Pixel Format  : 'GREY'
Field         : None
Bytes per Line: 160
Size Image    : 19200
Colorspace    : SRGB
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 30.000 (30/1)
Write buffers    : 8
                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0
kenm@kenm-Studio-XPS-8000 ~/FLIR_ONE/thomas123/New_test/v4l $  v4l2-ctl --all -d /dev/video1
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0001)
Bus info      : v4l2loopback:1
Driver version: 0.8.0
Capabilities  : 0x05000003
Video Capture
Video Output
Read/Write
Streaming
Video input : 0 (loopback: ok)
Video output: 0 (loopback in)
Format Video Capture:
Width/Height  : 640/480
Pixel Format  : 'BGR4'
Field         : None
Bytes per Line: 2560
Size Image    : 1228800
Colorspace    : SRGB
Format Video Output:
Width/Height  : 640/480
Pixel Format  : 'BGR4'
Field         : None
Bytes per Line: 2560
Size Image    : 1228800
Colorspace    : SRGB
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 30.000 (30/1)
Write buffers    : 8
                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0

So it looks like maybe this is a versioning problem, because I am using what comes with Linux Mint17.3 and you are maybe using something compiled from source or at least a more recent version.

I think I'll try getting v4l2loopback from github and replace what comes with Mint17.3.

I've tried using /dev/video2 and it makes no difference.
I've tried with and without  "exclusive_caps", and it makes no difference.

"Driver version: 3.18.13"
vs my:
"Driver version: 0.8.0"
worries me.

As does my:
Current format: BGR32

   ...ken...

 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #108 on: December 30, 2015, 02:10:10 am »
my suggest:

try to write the real video to /dev/video0 and thermal to /dev/video1 and see what happens
Code: [Select]
#define VIDEO_DEVICE0 "/dev/video1"
#define FRAME_WIDTH0  160
#define FRAME_HEIGHT0 120

#define VIDEO_DEVICE1 "/dev/video0"
#define FRAME_WIDTH1  640
#define FRAME_HEIGHT1 480

because we write
Code: [Select]
#define FRAME_FORMAT1 V4L2_PIX_FMT_MJPEGand you get
Code: [Select]
Pixel Format  : 'BGR4'instead
Code: [Select]
Pixel Format  : 'MJPG'

BGR4 = V4L2_PIX_FMT_BGR32



version 3.18.13 looks like my kernel version on raspberry   :-\
Code: [Select]
$ v4l2-ctl --info
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0000)
Bus info      : platform:v4l2loopback-000
Driver version: 3.18.13
Capabilities  : 0x85208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x05208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming

Code: [Select]
$ uname -a
Linux raspberryLCD 3.18.13-v7+ #784 SMP PREEMPT Sat May 9 15:57:36 BST 2015 armv7l GNU/Linux

I posted my installations steps here:

the next steps for installing v4l2loopback are simple
Code: [Select]
$ uname -a
Linux raspberryLCD 3.18.0-trunk-rpi2 #1 SMP PREEMPT Debian 3.18.5-1~exp1+rpi19 (2015-08-08) armv7l GNU/Linux

$ git clone https://github.com/umlaeute/v4l2loopback

$ cd v4l2loopback

$ make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/pi/v4l2loopback/v4l2loopback modules
make[1]: Entering directory '/usr/src/linux-headers-3.18.0-trunk-rpi2'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
  CC [M]  /home/pi/v4l2loopback/v4l2loopback/v4l2loopback.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/pi/v4l2loopback/v4l2loopback/v4l2loopback.mod.o
  LD [M]  /home/pi/v4l2loopback/v4l2loopback/v4l2loopback.ko
make[1]: Leaving directory '/usr/src/linux-headers-3.18.0-trunk-rpi2'

$ sudo su

# make install
make -C /lib/modules/`uname -r`/build M=/home/pi/v4l2loopback/v4l2loopback modules_install
make[1]: Entering directory '/usr/src/linux-headers-3.18.0-trunk-rpi2'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
  INSTALL /home/pi/v4l2loopback/v4l2loopback/v4l2loopback.ko
  DEPMOD  3.18.0-trunk-rpi2
make[1]: Leaving directory '/usr/src/linux-headers-3.18.0-trunk-rpi2'
depmod -a  `uname -r`

$ sudo modprobe v4l2loopback

$ lsmod
Module                  Size  Used by
v4l2loopback           23372  0

...

« Last Edit: December 30, 2015, 02:31:21 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #109 on: December 30, 2015, 02:34:19 am »
Just changing

Code: [Select]
#define VIDEO_DEVICE0 "/dev/video1"
#define FRAME_WIDTH0  160
#define FRAME_HEIGHT0 120

#define VIDEO_DEVICE1 "/dev/video0"
#define FRAME_WIDTH1  640
#define FRAME_HEIGHT1 480

 video1 is recognized by Guvcview and mplayer displays the thermal image, video0 is garbage


...disregard the below screenshot...
« Last Edit: December 30, 2015, 02:41:28 am by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #110 on: December 30, 2015, 02:50:14 pm »
Hi cynfab,

2 hours work:
I installed a Linux Mint Image on a clean notebook and note all steps  ;)

(for another readers: Linux Mint as a Ubuntu fork)


$ uname -a
Linux mint-Lenovo-B50-70 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ inxi -S
System:    Host: mint-Lenovo-B50-70 Kernel: 3.19.0-32-generic x86_64 (64 bit) Desktop: N/A
           Distro: Linux Mint 17.3 Rosa

$ sudo apt-get install g++

// check pre-installed libusb versions
$ dpkg --get-selections | grep libusb
libusb-0.1-4:amd64install
libusb-1.0-0:amd64install
libusb-1.0-0:i386install
libusbmuxd2install

// we need the header file libusb.h
$ sudo apt-get install libusb-1.0-0-dev

// check the path of libusb.h for gcc command line below
$ find / -name libusb.h 2>/dev/zero
/usr/include/libusb-1.0/libusb.h

// I see my notebook webcam as device video0
$ ls /dev/video*
/dev/video0

// there is no v4l2loopback driver installed on clean Linux Mint
$ lsmod | grep v4l2
v4l2_common            16384  1 videobuf2_core
videodev              159744  3 uvcvideo,v4l2_common,videobuf2_core

$ sudo modprobe v4l2loopback
modprobe: FATAL: Module v4l2loopback not found.

// therefore me must compile the driver for our kernel
// first load kernel sources (try to skip this step)
$ sudo apt-get install linux-generic

// 271 MB later: I think this was to much.
// Better load only the kernel headers (as part of the packet linux-generic)
$ sudo apt-get install linux-headers-generic

// try to compile v4l2loopback with packet manager (skip this step)
$ sudo apt-get install v4l2loopback-dkms
...
Building initial module for 3.19.0-32-generic
Error! Bad return status for module build on kernel: 3.19.0-32-generic (x86_64)
Consult /var/lib/dkms/v4l2loopback/0.8.0/build/make.log for more information.

// Argh! We got an Error!!
$ cat /var/lib/dkms/v4l2loopback/0.8.0/build/make.log
..
/var/lib/dkms/v4l2loopback/0.8.0/build/v4l2loopback.c:486:2: error: implicit declaration of function ‘strict_strtoul’ [-Werror=implicit-function-declaration]
  if (strict_strtoul(buf, 0, &curr))
  ^
...
make: *** [v4l2loopback.ko] Error 2

// first remove the broken packet v4l2loopback-dkms...
$ sudo apt-get remove v4l2loopback-dkms
...
Entfernen von v4l2loopback-dkms (0.8.0-1) ...
------------------------------
Deleting module version: 0.8.0
completely from the DKMS tree.
------------------------------

// ... then do it yourself
$ sudo apt-get install git

$ git clone https://github.com/umlaeute/v4l2loopback

$ cd v4l2loopback/

$ make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/mint/Desktop/flir/v4l2loopback modules
make[1]: Verzeichnis »/usr/src/linux-headers-3.19.0-32-generic« wird betreten
  CC [M]  /home/mint/Desktop/flir/v4l2loopback/v4l2loopback.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/mint/Desktop/flir/v4l2loopback/v4l2loopback.mod.o
  LD [M]  /home/mint/Desktop/flir/v4l2loopback/v4l2loopback.ko

$ sudo make install
make -C /lib/modules/`uname -r`/build M=/home/mint/Desktop/flir/v4l2loopback modules_install
  INSTALL /home/mint/Desktop/flir/v4l2loopback/v4l2loopback.ko

// now load video1 and video2 (because my notebook cam is video0)
$ sudo modprobe v4l2loopback video_nr=1,2

// check it - all works fine
$ ls /dev/video*
/dev/video0  /dev/video1  /dev/video2

// edit /dev/video? in  flir8g-mint.c
#define VIDEO_DEVICE0 "/dev/video1"
#define FRAME_WIDTH0  160
#define FRAME_HEIGHT0 120

#define VIDEO_DEVICE1 "/dev/video2"
#define FRAME_WIDTH1  640
#define FRAME_HEIGHT1 480

// compile flir8g-mint.c from attachment
$ /usr/bin/gcc '-I/usr/include/libusb-1.0'  -o flir1 flir8g-mint.c -lusb-1.0 -lm

// and run the code
$ sudo ./flir
...
#000037 68/10 fps:{"shutterState":"ON","shutterTemperature":294.489990234375,"usbNotifiedTimestamp":1176135054.68748,"usbEnqueuedTimestamp":1176135054.68923,"ffcState":"FFC_RAD_APPROX"}
#000038 71/10 fps:{"shutterState":"ON","shutterTemperature":294.489990234375,"usbNotifiedTimestamp":1176135054.8017,"usbEnqueuedTimestamp":1176135054.80321,"ffcState":"FFC_RAD_APPROX"}
#000039 70/10 fps:{"shutterState":"ON","shutterTemperature":294.489990234375,"usbNotifiedTimestamp":1176135054.91573,"usbEnqueuedTimestamp":1176135054.91749,"ffcState":"FFC_RAD_APPROX"}
...

// another session
$ sudo apt-get install v4l-utils

$ v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video1

Dummy video device (0x0001) (platform:v4l2loopback-001):
/dev/video2

Lenovo EasyCamera (usb-0000:00:14.0-6):
/dev/video0

// check correct formats
$ v4l2-ctl --list-formats-out -d /dev/video1
ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Output
Pixel Format: 'GREY'
Name        : 8 bpp, Greyscale

$ v4l2-ctl --list-formats-out -d /dev/video2
ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Output
Pixel Format: 'MJPG'
Name        : Motion-JPEG

// install guvcview and mplayer
$ sudo apt-get install guvcview
$ sudo apt-get install mplayer


... and all works fine:


only for comparing the "Driver version":
Code: [Select]
$ v4l2-ctl --all -d /dev/video2
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0001)
Bus info      : platform:v4l2loopback-001
Driver version: 3.19.8
Capabilities  : 0x85208003
Video Capture
Video Output
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x85208003
Video Capture
Video Output
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Video input : 0 (loopback: ok)
Video output: 0 (loopback in)
Format Video Capture:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Format Video Output:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Streaming Parameters Video Capture:
Frames per second: 30.000 (30/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 30.000 (30/1)
Write buffers    : 8

User Controls

                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0
« Last Edit: December 30, 2015, 03:25:58 pm by tomas123 »
 
The following users thanked this post: Niels2

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #111 on: December 30, 2015, 03:06:19 pm »
Hi tomas123,
Nice job detailing all of that.

I believe that the issue I am having is the old version of v4l2loopback that comes with Mint17.3's v4l2loopback-dkms.
I'll get a chance to rebuild it later this morning.
I've got to deal with another 3-4" of new snow, so thermal imaging will have to wait a bit :)

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #112 on: December 30, 2015, 03:15:11 pm »
I was to curios about your error and thought that it's faster to try it self as write dozen posts in my broken english  :-+

Don't forget to clean your driver:

Code: [Select]
$ dpkg --get-selections | grep v4l2
$ sudo apt-get remove v4l2loopback-dkms


« Last Edit: December 30, 2015, 03:16:54 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #113 on: December 30, 2015, 05:09:55 pm »
Thanks,
I cleaned out the old v4l2loopback, but am having issues compiling the new one.
With just a plain make, somehow it thinks I want to cross compile for arm. |O
Just updated the kernel to 3.19.0-32, but that made no difference,

Code: [Select]
make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/kenm/FLIR_ONE/thomas123/v4l2loopback modules
make[1]: Entering directory `/usr/src/linux-headers-3.19.0-32-generic'
  CC [M]  /home/kenm/FLIR_ONE/thomas123/v4l2loopback/v4l2loopback.o
In file included from include/asm-generic/int-ll64.h:10:0,
                 from ./arch/arm/include/asm/types.h:4,
                 from include/uapi/linux/types.h:4,
                 from include/linux/compiler.h:189,
                 from include/linux/linkage.h:4,
                 from include/linux/preempt.h:9,
                 from include/linux/spinlock.h:50,
                 from include/linux/vmalloc.h:4,
                 from /home/kenm/FLIR_ONE/thomas123/v4l2loopback/v4l2loopback.c:17:
include/uapi/asm-generic/int-ll64.h:11:29: fatal error: asm/bitsperlong.h: No such file or directory
compilation terminated.

It's just one of those days.....

   ...ken...

|O
NOOB mistake... had something set in .profile ARCH=arm |O

And now flir8g works perfectly!!

« Last Edit: December 30, 2015, 05:25:21 pm by cynfab »
 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #114 on: December 30, 2015, 06:42:46 pm »
Nice work guys

RESPECT 👍
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #115 on: December 31, 2015, 01:44:15 am »
Hi tomas123,

For your thermal imaging pleasure, a version that does 3 video streams,
one is greyscale thermal
another is visual
and the third is a colorized version of the thermal image.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #116 on: January 02, 2016, 01:17:38 am »
Hi cynfab,

your lookup table works great.
But first edit your memory leak by freeing fb_proc2.
(Watch the growing virtual memory of process flir8h with top.)

flir8h.c 
Code: [Select]
...
326:   free(fb_proc);
327:   free(fb_proc2);
...


... but we cant select our frame format V4L2_PIX_FMT_GREY in motion.conf  :(
As nice side effect, we have now a V4L2 thermal stream, which motion can process.
http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome

$ make
gcc -I/usr/include/libusb-1.0    -c -o flir8h.o flir8h.c
gcc -I/usr/include/libusb-1.0 -o flir8h Palettes.o flir8h.o -lusb-1.0 -lm -Wall

$ sudo ./flir8h

// install motion
$ sudo apt-get install motion

// edit config file
$ sudo nano /etc/motion/motion.conf

Code: [Select]
# Maximum framerate for webcam streams (default: 1)
webcam_maxrate 10

# Restrict webcam connections to localhost only (default: on)
webcam_localhost off

# thread config files.
thread /usr/local/etc/thread1.conf
thread /usr/local/etc/thread2.conf
; thread /usr/local/etc/thread3.conf
; thread /usr/local/etc/thread4.conf

// create two additional config files for /dev/video2 and /dev/video3
Code: [Select]
$ cat /usr/local/etc/thread1.conf
# V4L2_PIX_FMT_MJPEG   : 2  'MJPEG'
# V4L2_PIX_FMT_JPEG    : 3  'JPEG'
# V4L2_PIX_FMT_RGB24   : 4  'RGB3'
v4l2_palette 2
videodevice /dev/video2
target_dir /tmp/motion2
webcam_port 8081

$ cat /usr/local/etc/thread2.conf
# V4L2_PIX_FMT_MJPEG   : 2  'MJPEG'
# V4L2_PIX_FMT_JPEG    : 3  'JPEG'
# V4L2_PIX_FMT_RGB
v4l2_palette 4
videodevice /dev/video3
target_dir /tmp/motion3
webcam_port 8082

install apache2 and create a simple html file
(192.168.1.70 is the ip address from my raspberry pi)
Code: [Select]
$ cat /var/www/index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
text-align:center;
background-color:#000000;
}
.container {
width:100%;
}
.motion1 {
border: 0;
width: 40%;
height: auto;
}
.motion2 {
border: 0;
width: 40%;
height: auto;
}
.clear {
clear:both;
}
</style>
</head>
<body>
<a href="http://192.168.1.70:8081"><img class="motion1" src="http://192.168.1.70:8081" /></a>

<a href="http://192.168.1.70:8082"><img class="motion2" src="http://192.168.1.70:8082" /></a>
</body>
</html>

open URL of server in a browser
« Last Edit: January 02, 2016, 01:22:54 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #117 on: January 02, 2016, 04:41:40 am »
Hi tomas123,
Happy New Year....
Yep, I found and fixed the memory leak soon after my last post.

The motion stuff is cool, gotta find some time to play with it.
But, I need a way to combine the visual and thermal images as in your attachment but I don't need motion detection, just the side by side display.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #118 on: January 02, 2016, 12:04:14 pm »
Hi cynfab,

A Happy New Year from non snowy Germany ;)

I don't need motion detection, just the side by side display.

I tested last days some streaming tools for V4L2.
A good entry point are this samples:
https://github.com/umlaeute/v4l2loopback/wiki
For the side by side display you can use the html template from my last post.

Here are my raw notes. All samples for our mjpeg stream /dev/video2:



MJPG-Streamer works great on Raspberry Pi and requires only 2% of CPU, because this tool only move the jpeg image without decoding/encoding.

installation guide
http://www.steinvoorte.nl/mjpgstreamer/index.php?page=2

install
Code: [Select]
$ sudo apt-get install libjpeg8-dev imagemagick subversion libv4l-dev

$ ls /usr/include/linux/videodev*
/usr/include/linux/videodev2.h

$ sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h

$ wget http://sourceforge.net/code-snapshots/svn/m/mj/mjpg-streamer/code/mjpg-streamer-code-182.zip

$ unzip mjpg-streamer-code-182.zip

$ cd mjpg-streamer-code-182/mjpg-streamer

// select required plugin (i.e. input_file.so)
$ make USE_LIBV4L2=true mjpg_streamer input_uvc.so  output_http.so

// install (note, that apache2 use /var/www )
$ sudo cp -R www /usr/local/www
$ sudo cp mjpg_streamer /usr/local/bin
$ sudo cp output_http.so  input_uvc.so /usr/local/lib/

start (note LD_LIBRARY_PATH to input_uvc.so)
Code: [Select]
$ export LD_LIBRARY_PATH=/usr/local/lib
$ mjpg_streamer -i "input_uvc.so -d /dev/video2" -o "output_http.so -w /usr/local/www"
 i: Using V4L2 device.: /dev/video2
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
...
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

open the stream on a second Notebook
with GUI:  http://192.168.1.70:8080
Stream only: http://192.168.1.70:8080/?action=stream

unfortunately mjpg_streamer only eats mjpeg and not RGB24 /dev/video3



fswebcam is a nice tool for create (single) images with timestamps etc. from a V4L2 device

http://manpages.ubuntu.com/manpages/lucid/man1/fswebcam.1.html
Code: [Select]
$ sudo apt-get install fswebcam

$ fswebcam --device /dev/video3 1.jpg
--- Opening /dev/video3...
Trying source module v4l2...
/dev/video3 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 160x120.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Writing JPEG image to '1.jpg'.
result:


Nice for a web site with a periodic refresh
Code: [Select]
<META HTTP-EQUIV="refresh" CONTENT="15">
more complex example:
Code: [Select]
fswebcam -D 3 -S 10 -F 10 -r 1280x720 -d /dev/video0 \  --font "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf:12" \  --title "Kamera 1" --subtitle "Hallo World" \  --timestamp "%d.%m.%Y %H:%M" --info "info" $FILE


avconv / ffmpeg

my sample is for avconv
http://libav.org/avconv.html

Code: [Select]
sudo apt-get install libav-tools

CPU consumption on raspberry pi (top)
VGA 640x480 150% CPU
gray 160x120 25% CPU

ffmpeg/avconv can't work as really server but you can stream to a device (my notebook is 192.168.1.42):
Code: [Select]
$ avconv -f video4linux2 -i /dev/video2 -vcodec mpeg2video -r 25 -pix_fmt yuv420p -me_method epzs -b 2600k -bt 256k -f rtp rtp://192.168.1.42:1234
avconv version 9.14-6:9.14-1rpi1rpi1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 22 2014 15:08:12 with gcc 4.6 (Debian 4.6.3-14+rpi1)
[video4linux2 @ 0xdc3740] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video2':
  Duration: N/A, start: 1451736986.645583, bitrate: N/A
    Stream #0.0: Video: mjpeg, yuvj422p, 640x480, 0 kb/s, 1000k tbn, 5 tbc
Output #0, rtp, to 'rtp://192.168.1.42:1234':
  Metadata:
    encoder         : Lavf54.20.4
    Stream #0.0: Video: mpeg2video, yuv420p, 640x480, q=2-31, 2600 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg -> mpeg2video)
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.42
t=0 0
a=tool:libavformat 54.20.4
m=video 1234 RTP/AVP 32
b=AS:2600

Press ctrl-c to stop encoding
frame=  437 fps= 24 q=4.2 size=    5613kB time=17.40 bitrate=2642.5kbits/s   

on client 192.168.1.42 open the stream on localhost ;-)
Code: [Select]
vlc / open network 
     rtp://@:1234


With VLC I received not good results.

Code: [Select]
$ cvlc v4l2:// :v4l2-dev=/dev/video2 :v4l2-width=640 :v4l2-height=480 --sout '#transcode{vcodec=mp4v,vb=128}:rtp{sdp=rtsp://:8554/live.ts}"' -I dummy
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x845c40] inhibit interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0x845c40] main interface error: no suitable interface module
[0x74e00a28] main interface error: no suitable interface module
[0x6d98f0] main libvlc error: interface "globalhotkeys,none" initialization failed
[0x8495f0] dummy interface: using the dummy interface module...
[mpeg4 @ 0x730f80] removing common factors from framerate
[mjpeg @ 0x71ba20] error count: 65
[mjpeg @ 0x71ba20] error y=8 x=4
[mjpeg @ 0x71ba20] error count: 64
[mjpeg @ 0x71ba20] error y=10 x=29
[mjpeg @ 0x71ba20] mjpeg: unsupported coding type (c9)
[mjpeg @ 0x71ba20] error count: 66
[mjpeg @ 0x71ba20] error y=19 x=32
[mjpeg @ 0x71ba20] error count: 65
[mjpeg @ 0x71ba20] error y=20 x=31
[mjpeg @ 0x71ba20] only 8 bits/component accepted
[mpeg4 @ 0x7095a0] removing common factors from framerate
[mjpeg @ 0x71ba20] No JPEG data found in image
[mjpeg @ 0x71ba20] No JPEG data found in image

There is also the known feature/error
Code: [Select]
VLC is not supposed to be run as root. Sorry.
« Last Edit: January 02, 2016, 12:29:24 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #119 on: January 02, 2016, 03:10:33 pm »
Hi tomas123,
Thanks for the pointers,
I've used MJPG-Streamer on an NSLU2 for a long time  thanks to this site:

https://johnarthur.wordpress.com/2008/03/25/a-high-resolution-ip-webcam/

VLC is somewhat overkill as is ffmpeg, as they are both doing decode --> encode which gobbles up CPU cycles.
I have a pcduino nano lite which uses an Allwinner A20 as my current test system, but a single core iMX6 is the actual target. No local display though.
I guess I really need to get an iMX6 board to test with :P

   ...ken...
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #120 on: January 03, 2016, 06:07:29 pm »
Hi tomasw123,
Check this out:

https://github.com/ccrisan/motioneyeos/wiki

It is motion based, I have it running on a RPi orig B with a UVC webcam, it seems a bit slow, but the RPi is a real dog....

I'd bet they would be interested in integrating the flir8h driver... :)

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #121 on: January 03, 2016, 09:05:46 pm »
I know this project ;-)
and I hope that Flir sells more F1 to the community.

I've used MJPG-Streamer on an NSLU2 for a long time
My concept was, to start the mjpg_streamer for /dev/video2 and /dev/video3 and place the two streams side by side on a web front end.
As I wrote before, mjpg_streamer only accepts mjpeg and YUV streams as input.

For inspiration as attachment a new version which writes the colorized RGB Thermal Image as MJPEG to /dev/video3
It needs the libjpeg library with libjpeg-dev (my path is /usr/include/jpeglib.h).
Code: [Select]
$ sudo apt-get install  libjpeg-dev
The code works fine...
Code: [Select]
$ make
gcc -I/usr/include/libusb-1.0 -o flir8i Palettes.o flir8i.o -lusb-1.0 -ljpeg -lm -Wall

$ sudo ./flir8i
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
using output device: /dev/video1
     vid_format->type                =2
     vid_format->fmt.pix.width       =160
     vid_format->fmt.pix.height      =120
     vid_format->fmt.pix.pixelformat =1497715271
     vid_format->fmt.pix.sizeimage   =20480
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=160
     vid_format->fmt.pix.colorspace  =8
using output device: /dev/video2
     vid_format->type                =2
     vid_format->fmt.pix.width       =640
     vid_format->fmt.pix.height      =480
     vid_format->fmt.pix.pixelformat =1196444237
     vid_format->fmt.pix.sizeimage   =1228800
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=0
     vid_format->fmt.pix.colorspace  =8
using output device: /dev/video3
     vid_format->type                =2
     vid_format->fmt.pix.width       =160
     vid_format->fmt.pix.height      =120
     vid_format->fmt.pix.pixelformat =1196444237
     vid_format->fmt.pix.sizeimage   =77824
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=0
     vid_format->fmt.pix.colorspace  =8

... with gucview and mplayer:
Quote
$ mplayer tv:// -tv driver=v4l2:device=/dev/video3
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
Playing tv://.
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
 comment: first try, more to come ;-)
v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
Selected device: Dummy video device (0x0003)
 Capabilities:  video capture  read/write  streaming
 supported norms:
 inputs: 0 = loopback;
 Current input: 0
Current format: MJPEG
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG)
==========================================================================
Audio: no sound
Starting playback...
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
VO: [gl_nosw] 160x120 => 160x120 Planar YV12
V:   0.0 278/278 ??% ??% ??,?% 0 0

But unfortunately mjpg_streamer has a problem with a mjpeg stream 160x120.
I don't know why.
Quote
$ export LD_LIBRARY_PATH=/usr/local/lib

$ mjpg_streamer -i "input_uvc.so -d /dev/video3 -r 160x120" -o "output_http.so -w /usr/local/www"
MJPG Streamer Version: svn rev: Unversioned directory
 i: Using V4L2 device.: /dev/video3
 i: Desired Resolution: 160 x 120
 i: Frames Per Second.: 5
i: Format............: MJPEG
...
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
*** glibc detected *** mjpg_streamer: free(): invalid next size (normal): 0x01258910 ***
Aborted

with MJPEG on /dev/video2 it works fine
Code: [Select]
$ mjpg_streamer -i "input_uvc.so -d /dev/video2" -o "output_http.so -w /usr/local/www"
MJPG Streamer Version: svn rev: Unversioned directory
 i: Using V4L2 device.: /dev/video2
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
...
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled



PS: flir8i1.c is a working copy, which writes all colorized thermal frames as JPEGs to file with format #012345.jpg
« Last Edit: January 06, 2016, 10:20:50 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #122 on: January 03, 2016, 10:09:48 pm »
tomas123,
When I display the colorized jpeg stream with guvcview, the color palette is messed up. could this be part of the problem with mpeg-streamer?

But when I change the guvcview vid controls to RGB3 the colors are ok. Hmmmm..

   ...ken...
« Last Edit: January 03, 2016, 10:51:14 pm by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #123 on: January 04, 2016, 09:11:02 am »
When I display the colorized jpeg stream with guvcview, the color palette is messed up. could this be part of the problem with mpeg-streamer?
do you mean with guvcview on /dev/video3
-  flir8h with RGB24 (=RGB3)
- or flir8i with MJPEG ?

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #124 on: January 04, 2016, 03:05:48 pm »
I believe it was a cockpit problem, I had the guvcview color controls set to MJPEG for /dev/video3 and the resulting stream was green. I changed it to RGB3 and it was ok.
This was flir8i streaming a mjpeg stream on /dev/video3.
« Last Edit: January 04, 2016, 03:08:02 pm by cynfab »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #125 on: January 04, 2016, 11:39:54 pm »
I can't confirm that.
On my raspberry pi guvcview color controls is automatic set to MJPEG for /dev/video2 and /dev/video3 and all works fine  :-//

flir8i2.c (see attachment) writes all jpg frames for /dev/video2 and /dev/video3 to file

the only ones differences I found in the .jpg files was the subsampling (v2=/dev/video2 and v3=/dev/video3)
Code: [Select]
$ exiftool -YCb* \#0000010-v*.jpg
======== #0000010-v2.jpg
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
======== #0000010-v3.jpg
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
    2 image files read
both subsamplings are valid for MJPEG
but nevertheless I changed the code for libjpeg at line 353 for YCbCr4:2:2 subsampling   
Code: [Select]
    // 4:2:2 (2x1 1x1 1x1) - CrH 50% - CbH 50% - CrV 100% - CbV 100%
    cinfo.comp_info[0].h_samp_factor = 2; // Y
    cinfo.comp_info[0].v_samp_factor = 1;
    cinfo.comp_info[1].h_samp_factor = 1; // Cb
    cinfo.comp_info[1].v_samp_factor = 1;
    cinfo.comp_info[2].h_samp_factor = 1; // Cr
    cinfo.comp_info[2].v_samp_factor = 1;

Now I can't see a difference.
Quote
$ exiftool  \#0000010-v*.jpg
======== #0000010-v2.jpg
ExifTool Version Number         : 10.02
File Name                       : #0000010-v2.jpg
File Size                       : 7.7 kB
Resource Fork Size              : 286 bytes
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Image Width                     : 640
Image Height                    : 480
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Image Size                      : 640x480
Megapixels                      : 0.307

======== #0000010-v3.jpg
ExifTool Version Number         : 10.02
File Name                       : #0000010-v3.jpg
File Size                       : 11 kB
Resource Fork Size              : 286 bytes
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 160
Image Height                    : 120
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Image Size                      : 160x120
Megapixels                      : 0.019
    2 image files read

... except the missing JFIF in /video2

Code: [Select]
$ hexdump -n32 -C #0000010-v2.jpg
00000000  ff d8 ff c0 00 11 08 01  e0 02 80 03 01 21 00 02  |.............!..|
00000010  11 01 03 11 01 ff dd 00  04 00 28 ff db 00 84 00  |..........(.....|

$ hexdump -n32 -C  #0000010-v3.jpg
00000000  ff d8 ff e0 00 10 4a 46  49 46 00 01 01 00 00 01  |......JFIF......|
00000010  00 01 00 00 ff db 00 43  00 03 02 02 03 02 02 03  |.......C........|

no differences in the announcements of the v4l2 loopback devices
Code: [Select]
$ v4l2-ctl --all -d /dev/video2
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0002)
Bus info      : platform:v4l2loopback-002
Driver version: 3.18.13
Capabilities  : 0x85208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x05208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Video input : 0 (loopback: ok)
Format Video Capture:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Format Video Output:
Width/Height  : 640/480
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 1228800
Colorspace    : SRGB
Custom Info   : feedcafe
Streaming Parameters Video Capture:
Frames per second: 5.000 (5/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 5.000 (5/1)
Write buffers    : 8

User Controls

                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0

$ v4l2-ctl --all -d /dev/video3
Driver Info (not using libv4l2):
Driver name   : v4l2 loopback
Card type     : Dummy video device (0x0003)
Bus info      : platform:v4l2loopback-003
Driver version: 3.18.13
Capabilities  : 0x85208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Device Capabilities
Device Caps   : 0x05208001
Video Capture
Video Memory-to-Memory
Read/Write
Streaming
Video input : 0 (loopback: ok)
Format Video Capture:
Width/Height  : 160/120
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 76800
Colorspace    : SRGB
Custom Info   : feedcafe
Format Video Output:
Width/Height  : 160/120
Pixel Format  : 'MJPG'
Field         : None
Bytes per Line: 0
Size Image    : 76800
Colorspace    : SRGB
Custom Info   : feedcafe
Streaming Parameters Video Capture:
Frames per second: 5.000 (5/1)
Read buffers     : 8
Streaming Parameters Video Output:
Frames per second: 5.000 (5/1)
Write buffers    : 8

User Controls

                    keep_format (bool)   : default=0 value=0
              sustain_framerate (bool)   : default=0 value=0
                        timeout (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io (bool)   : default=0 value=0

But still mjpg_streamer has the same problem with the mjpeg stream 160x120.
Code: [Select]
$ export LD_LIBRARY_PATH=/usr/local/lib

$ mjpg_streamer -i "input_uvc.so -d /dev/video3 -r 160x120" -o "output_http.so -w /usr/local/www"
MJPG Streamer Version: svn rev: Unversioned directory
 i: Using V4L2 device.: /dev/video3
 i: Desired Resolution: 160 x 120
 i: Frames Per Second.: 5
i: Format............: MJPEG
...
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
*** glibc detected *** mjpg_streamer: free(): invalid next size (normal): 0x01258910 ***
Aborted

Is 160x120 to small for mjpg_streamer?
« Last Edit: January 04, 2016, 11:57:35 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #126 on: January 05, 2016, 01:13:33 am »
tomas123,
Maybe we should expanding the 160 x 120 image to 320 x 240. just a quick scaling by 2 should be enough to see if there is a minimum size issue.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #127 on: January 06, 2016, 11:43:42 pm »
Yes, with an upscaled image to 320 x 240 mjpg_streamer works fine without a buffer/pointer error.
Code: [Select]
./mjpg_streamer -i "./input_uvc.so -d /dev/video3" -o "output_http.so -w /usr/local/www"

I wasted many time for this bug  >:(

Quote
Open and edit the apporitate plugins (input_uvc) and the programs Makefile, and remove the hashmark befor the following row:
#CFLAGS +=  -DDEBUG
After debugging the mjpg_streamer source code  I know, that the error comes from the second (!) grabbed frame

Code: [Select]
$ ./mjpg_streamer -i "./input_uvc.so -d /dev/video3" -o "output_http.so -w /usr/local/www"
MJPG Streamer Version: svn rev: 3:172M
 DBG(input_uvc.c, input_init(), 107): argv[0]=UVC webcam grabber
 DBG(input_uvc.c, input_init(), 107): argv[1]=-d
 DBG(input_uvc.c, input_init(), 107): argv[2]=/dev/video3
 DBG(input_uvc.c, input_init(), 162): case 2,3
 DBG(input_uvc.c, input_init(), 245): input id: 0
 i: Using V4L2 device.: /dev/video3
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
 DBG(input_uvc.c, input_init(), 265): vdIn pn: 0
i: The format asked unavailable, so the width 160 height 120
 DBG(v4l2uvc.c, init_videoIn(), 94): Current size: 160x120
 DBG(v4l2uvc.c, init_videoIn(), 123): Supported format: [MJPG]
 DBG(v4l2uvc.c, init_videoIn(), 153): Supported size with the current format: 160x120
 DBG(v4l2uvc.c, init_videoIn(), 123): Supported format: RGB3
 DBG(v4l2uvc.c, init_videoIn(), 155): Supported size: 160x120
 DBG(v4l2uvc.c, init_videoIn(), 123): Supported format: BGR3
 DBG(v4l2uvc.c, init_videoIn(), 155): Supported size: 160x120
 DBG(v4l2uvc.c, init_videoIn(), 123): Supported format: YU12
 DBG(v4l2uvc.c, init_videoIn(), 155): Supported size: 160x120
 DBG(v4l2uvc.c, init_videoIn(), 123): Supported format: YV12
 DBG(v4l2uvc.c, init_videoIn(), 155): Supported size: 160x120
...
 DBG(v4l2uvc.c, enumerateControls(), 801): V4L2 API's V4L2_CTRL_FLAG_NEXT_CTRL is supported
 DBG(v4l2uvc.c, control_readed(), 705): V4L2 parameter found: User Controls value 2123345140 Class: USER
 DBG(v4l2uvc.c, control_readed(), 710): Unable to get the value of User Controls retcode: -1  Permission denied
 DBG(v4l2uvc.c, control_readed(), 705): V4L2 parameter found: keep_format value 0 Class: USER
 DBG(v4l2uvc.c, control_readed(), 705): V4L2 parameter found: sustain_framerate value 0 Class: USER
 DBG(v4l2uvc.c, control_readed(), 705): V4L2 parameter found: timeout value 0 Class: USER
 DBG(v4l2uvc.c, control_readed(), 705): V4L2 parameter found: timeout_image_io value 0 Class: USER
 DBG(v4l2uvc.c, enumerateControls(), 836): JPEG compression details:
 DBG(v4l2uvc.c, enumerateControls(), 837): Quality: 0
 DBG(v4l2uvc.c, enumerateControls(), 838): APPn: 0
 DBG(v4l2uvc.c, enumerateControls(), 839): APP length: 0
 DBG(v4l2uvc.c, enumerateControls(), 840): APP data:
 DBG(v4l2uvc.c, enumerateControls(), 841): COM length: 0
 DBG(v4l2uvc.c, enumerateControls(), 842): COM data:
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
 DBG(input_uvc.c, input_run(), 310): launching camera thread #00
,sizeof(struct v4l2_buffer) DBG(v4l2uvc.c, uvcGrab(), 431): X3
 DBG(input_uvc.c, cam_thread(), 382): received frame of size: 76800 from plugin: 0
 DBG(input_uvc.c, cam_thread(), 411): copying frame from input: 0
 DBG(input_uvc.c, cam_thread(), 436): waiting for next frame
*** glibc detected *** ./mjpg_streamer: free(): invalid next size (normal): 0x000ee9d8 ***
Aborted

the errors comes from this line:

input_uvc.c
Code: [Select]
             /* grab a frame */
377:        if(uvcGrab(pcontext->videoIn) < 0) {

this goes to V4l2 command VIDIOC_DQBUF
v4l2uvc.c
Code: [Select]
int uvcGrab(struct vdIn *vd)
{
430:     vd->buf.memory = V4L2_MEMORY_MMAP;
431:     ret = xioctl(vd->fd, VIDIOC_DQBUF, &vd->buf);

with

Code: [Select]
static int xioctl(int fh, int request, void *arg)
{
        int r;
        do
        {
            r = ioctl(fh, request, arg);
        } while (-1 == r && EINTR == errno);
        return r;
}

but I found no solution



only for information:


... except the missing JFIF in /video2

Code: [Select]
$ hexdump -n32 -C #0000010-v2.jpg
00000000  ff d8 ff c0 00 11 08 01  e0 02 80 03 01 21 00 02  |.............!..|
00000010  11 01 03 11 01 ff dd 00  04 00 28 ff db 00 84 00  |..........(.....|

$ hexdump -n32 -C  #0000010-v3.jpg
00000000  ff d8 ff e0 00 10 4a 46  49 46 00 01 01 00 00 01  |......JFIF......|
00000010  00 01 00 00 ff db 00 43  00 03 02 02 03 02 02 03  |.......C........|


Quote
Motion JPEG AVI files typically have an APP0 header (FF E0), with the tag 'AVI1' and not 'JFIF'.

remove a JFIF header from jpeg with
Code: [Select]
  cinfo.write_JFIF_header = FALSE;
  jpeg_start_compress(&cinfo, TRUE);
« Last Edit: January 06, 2016, 11:51:42 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #128 on: January 07, 2016, 08:09:52 am »
Hi cynfab,

have you ever tried mjpg_streamer on your Linux Mint?

Today I tested it the first time on a Linux Mint Notebook with our old code flir8i.c
Reverse:
- real video stream 640x480 on /dev/video2 goes to a memory error
- thermal video stream 160x120 on /dev/video3 works fine

In the german ubuntu forum
https://wiki.ubuntuusers.de/MJPG-Streamer/
they describe, that the old Rev. 182 (Date 2008-06-21) of /mjpg_streamer is buggy while reading MJPEG.

I can confirm it. |O

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #129 on: January 07, 2016, 02:20:22 pm »
Hi tomas123,
No I haven't tried mjpeg-streamer on Mint. been busy & now snowed in again :)
Trying to get a new kernel built for my pcduino, and having some toolchain problems. Once I get that working I'll be trying the various flir8x, v4l2 & loopback code on it.

   ...ken...
 

Offline Ben321

  • Frequent Contributor
  • **
  • Posts: 506
Re: Question about FLIR One for Android
« Reply #130 on: January 08, 2016, 08:34:43 am »
When is FLIR going to start selling 160x120 Lepton chips as standalone components. I just recently checked their website and they link to Digikey which is selling the old 80x60 chips still. How long until the old ones sell out, so they can start selling the new version? And when (if ever) is FLIR going to start making true 320x240 or 640x480 Lepton chips? It seems they must have in the past couple years discovered a better manufacturing process for making vanadium oxide microbolometer chips, because 160x120 thermal imagers used to sell for about $2500, but the FLIR One costs only $250. If this is how dramatic they have been able to reduce the cost on 160x120 thermal images, I'm expecting them to eventually expand their range of super-cheap thermal imagers to eventually include ones with super-cheap 320x240, or even 640x480, VOX microbolometer chips (maybe a Lepton v4 or v5). Have you guys heard any rumors about any plans from FLIR for future versions of the Lepton chip that have a higher resolution than 160x120?
 

Offline Lord of nothing

  • Super Contributor
  • ***
  • Posts: 1271
  • Country: at
Re: Question about FLIR One for Android
« Reply #131 on: January 10, 2016, 01:24:10 pm »
are there any other company who make thermal sensors?
Made in Japan, destroyed in Sulz im Wienerwald.
 

Offline frenky

  • Supporter
  • ****
  • Posts: 971
  • Country: si
    • Frenki.net
Re: Question about FLIR One for Android
« Reply #132 on: January 10, 2016, 02:50:37 pm »
Check out this two:
http://www.i3system.com/eng/
http://www.heimannsensor.com/products_imaging.php

Sent from my LG-D855 using Tapatalk

 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #133 on: January 10, 2016, 04:44:17 pm »
a subforum for "Thermal Imaging"  :-+ :-+



Hi cynfab,

after terrible hours with a self compiled kernel driver (v4l2loopback.so) for ARM systems
Code: [Select]
$ find / -name v4l2loopback.ko 2>/dev/zero
/lib/modules/3.18.0-trunk-rpi2/extra/v4l2loopback.ko
/lib/modules/3.18.13-v7+/extra/v4l2loopback.ko

... I suggest new concept for using MJPEG Streamer with our Flir One:
Create a RAMDisk and use the input_file.so module of mjpg_streamer.
It works great with the low powered raspberry pi and you don't need the loopback devices /dev/videoX


(1) create a small ramdisk of 20MB

Code: [Select]
$ sudo mkdir /mnt/RAMDisk
$ sudo chmod 777 /mnt/RAMDisk

$ sudo mount -t tmpfs  -o size=20m none  /mnt/RAMDisk

$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
none               20480   20480         0 100% /mnt/RAMDisk


(2) compile the code flir8k.c from attachment


check your packages
Code: [Select]
$ sudo apt-get install libusb-1.0-0
$ sudo apt-get install libusb-1.0-0-dev
$ sudo apt-get install libjpeg-dev


Code: [Select]
$ make
gcc -I/usr/include/libusb-1.0    -c -o flir8k.o flir8k.c
gcc -I/usr/include/libusb-1.0 -o flir8k Palettes.o flir8k.o -lusb-1.0 -ljpeg -lm -Wall


(3) start the binary

now the binary writes the two images real.jpg and thermal.jpg to /mnt/RAMDisk/ with 8 fps

Code: [Select]
$ sudo ./flir8k
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

:xx Sun Jan 10 16:30:27 2016

: Sun Jan 10 16:30:27 2016
 bulk read EP 0x81, actual length 101
HEX:
 cc 01 00 00 01 00 00 00 55 00 00 00 30 73 8c df 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 56 6f 6c 74 61 67 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 76 6f 6c 74 61 67 65 22 3a 34 2e 31 37 30 30 30 30 30 37 36 32 39 33 39 35 2c 22 70 65 72 63 65 6e 74 61 67 65 22 3a 31 30 30 7d 7d 00
STRING:
?U0s??{"type":"batteryVoltageUpdate","data":{"voltage":4.17000007629395,"percentage":100}}

: Sun Jan 10 16:30:27 2016
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x83:-7 LIBUSB_ERROR_TIMEOUT

ask for CameraFiles.zip on EP 0x83:

: Sun Jan 10 16:30:28 2016

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 41 00 00 00 f8 b3 f7 00 ]

Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!
EP 0x02 to be sent 51 Bytes: {"type":"readFile","data":{"streamIdentifier":10}}
Write successful!
Sent 51 bytes with string: {"type":"readFile","data":{"streamIdentifier":10}}

: Sun Jan 10 16:30:28 2016


Ask for video stream, start EP 0x85:

: Sun Jan 10 16:30:28 2016
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81:-7 LIBUSB_ERROR_TIMEOUT
#000001 0/10 fps:{"shutterState":"ON","shutterTemperature":310.179992675781,"usbNotifiedTimestamp":1177004833.33163,"usbEnqueuedTimestamp":1177004833.33369,"ffcState":"FFC_VALID_RAD"}
#000002 0/10 fps:{"shutterState":"FFC","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004852.00896,"usbEnqueuedTimestamp":1177004852.01061,"ffcState":"FFC_RAD_APPROX"}

: Sun Jan 10 16:30:47 2016
 bulk read EP 0x81, actual length 206
HEX:
 cc 01 00 00 01 00 00 00 55 00 00 00 30 73 8c df 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 56 6f 6c 74 61 67 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 76 6f 6c 74 61 67 65 22 3a 34 2e 31 37 30 30 30 30 30 37 36 32 39 33 39 35 2c 22 70 65 72 63 65 6e 74 61 67 65 22 3a 31 30 30 7d 7d 00 cc 01 00 00 01 00 00 00 59 00 00 00 88 cc 5a 95 7b 22 74 79 70 65 22 3a 22 62 61 74 74 65 72 79 43 68 61 72 67 69 6e 67 53 74 61 74 65 55 70 64 61 74 65 22 2c 22 64 61 74 61 22 3a 7b 22 63 68 61 72 67 69 6e 67 53 74 61 74 65 22 3a 22 73 74 61 74 65 43 68 61 72 67 69 6e 67 53 6d 61 72 74 50 68 6f
STRING:
?U0s??{"type":"batteryVoltageUpdate","data":{"voltage":4.17000007629395,"percentage":100}}?Y??Z?{"type":"batteryChargingStateUpdate","data":{"chargingState":"stateChargingSmartPho
#000003 0/10 fps:{"shutterState":"FFC","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004852.57983,"usbEnqueuedTimestamp":1177004852.58155,"ffcState":"FFC_RAD_APPROX"}
#000004 3/10 fps:{"shutterState":"FFC","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004852.69227,"usbEnqueuedTimestamp":1177004852.69411,"ffcState":"FFC_RAD_APPROX"}
#000005 8/10 fps:{"shutterState":"ON","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004852.80562,"usbEnqueuedTimestamp":1177004852.80794,"ffcState":"FFC_RAD_APPROX"}
#000006 11/10 fps:{"shutterState":"ON","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004852.91994,"usbEnqueuedTimestamp":1177004852.92159,"ffcState":"FFC_RAD_APPROX"}
#000007 14/10 fps:{"shutterState":"ON","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004853.03383,"usbEnqueuedTimestamp":1177004853.03595,"ffcState":"FFC_RAD_APPROX"}
#000008 18/10 fps:{"shutterState":"ON","shutterTemperature":308.640014648438,"usbNotifiedTimestamp":1177004853.14999,"usbEnqueuedTimestamp":1177004853.15202,"ffcState":"FFC_RAD_APPROX"}
#000009 20/10 fps:{"shutterState":"ON","shutterTemperature":308.75,"usbNotifiedTimestamp":1177004853.26203,"usbEnqueuedTimestamp":1177004853.26407,"ffcState":"FFC_RAD_APPROX"}
#000010 23/10 fps:{"shutterState":"ON","shutterTemperature":308.75,"usbNotifiedTimestamp":1177004853.37733,"usbEnqueuedTimestamp":1177004853.37923,"ffcState":"FFC_RAD_APPROX"}
#000011 26/10 fps:{"shutterState":"ON","shutterTemperature":308.75,"usbNotifiedTimestamp":1177004853.49003,"usbEnqueuedTimestamp":1177004853.49223,"ffcState":"FFC_RAD_APPROX"}
#000012 28/10 fps:{"shutterState":"ON","shutterTemperature":308.769989013672,"usbNotifiedTimestamp":1177004853.60389,"usbEnqueuedTimestamp":1177004853.60574,"ffcState":"FFC_RAD_APPROX"}
...
#003170 86/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004033.54082,"usbEnqueuedTimestamp":1177004033.542,"ffcState":"FFC_VALID_RAD"}
#003171 84/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004033.65724,"usbEnqueuedTimestamp":1177004033.6585,"ffcState":"FFC_VALID_RAD"}
#003172 83/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004033.76884,"usbEnqueuedTimestamp":1177004033.77,"ffcState":"FFC_VALID_RAD"}
#003173 83/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004033.88303,"usbEnqueuedTimestamp":1177004033.89359,"ffcState":"FFC_VALID_RAD"}
#003174 84/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004034.00084,"usbEnqueuedTimestamp":1177004034.00196,"ffcState":"FFC_VALID_RAD"}
#003175 84/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004034.11106,"usbEnqueuedTimestamp":1177004034.11261,"ffcState":"FFC_VALID_RAD"}
#003176 84/10 fps:{"shutterState":"ON","shutterTemperature":310.679992675781,"usbNotifiedTimestamp":1177004034.2256,"usbEnqueuedTimestamp":1177004034.22683,"ffcState":"FFC_VALID_RAD"}

(4) run a web server on /var/www/

- like apache
Code: [Select]
$ sudo apt-get install apache2
- link the two files real.jpg and thermal.jpg from RAMDISK to web folder
- check your web folder (current apache on raspi is /var/www/html/thermal.jpg
Code: [Select]
$ sudo ln -s /mnt/RAMDisk/thermal.jpg /var/www/thermal.jpg
$ sudo ln -s /mnt/RAMDisk/real.jpg /var/www/real.jpg
// don't forget the "sudo chmod 777 /mnt/RAMDisk" from (1)  ;)

now you can see the two images in your web browser
Code: [Select]
http://192.168.1.70/real.jpg
http://192.168.1.70/thermal.jpg
my raspberry pi has the address 192.168.1.70


(5) View video stream on an iDevice / Smartphone

 load from apple app store ore google play store the free app IP Cam Viewer Lite from NibblesnBits

http://elinux.org/RPi-Cam-Web-Interface#View_video_stream_on_an_iDevice_.2F_Smartphone
Quote
Select the menu icon
Press Manage Cameras
Select Add Camera then Generic URL
Give your cam a name
For Type choose Generic Video URL
Enter your URL, e.g. http://192.168.0.1:80/thermal.jpg
Press Test
If it works, press Save

You can to it twice for thermal.jpg and real.jpg and then you see the two streams parallel.
It's a little bit rough for the large image real.jpg with 9fps over WLAN, but thermal.jpg works fine


(6) create two MJPEG streams for real and thermal image

compile mjpg-streamer from source
mjpg-streamer needs imagemagick
Code: [Select]
$ sudo apt-get install imagemagick
Code: [Select]
$ sudo apt-get install subversion
$ svn co svn://svn.code.sf.net/p/mjpg-streamer/code/ mjpg-streamer
...
Checked out revision 182.
$ cd mjpg-streamer/mjpg-streamer
$ make
gcc -D'SVN_REV="3:172"' -O2 -DLINUX -D_GNU_SOURCE -Wall    -c -o mjpg_streamer.o mjpg_streamer.c
gcc -D'SVN_REV="3:172"' -O2 -DLINUX -D_GNU_SOURCE -Wall    -c -o utils.o utils.c
gcc -D'SVN_REV="3:172"' -O2 -DLINUX -D_GNU_SOURCE -Wall  mjpg_streamer.o utils.o -lpthread -ldl -o mjpg_streamer
chmod 755 mjpg_streamer
make -C plugins/input_uvc all
...
cp plugins/input_file/input_file.so

$ ls -al
total 412
drwxr-xr-x  5 pi pi   4096 Jan 10 17:24 .
drwxr-xr-x 10 pi pi   4096 Jan 10 17:22 ..
-rw-r--r--  1 pi pi    102 Jan 10 17:22 CHANGELOG
-rwxr-xr-x  1 pi pi  14331 Jan 10 17:24 input_file.so
-rwxr-xr-x  1 pi pi 168606 Jan 10 17:24 input_testpicture.so
-rwxr-xr-x  1 pi pi  30905 Jan 10 17:24 input_uvc.so
-rw-r--r--  1 pi pi  17987 Jan 10 17:22 LICENSE
-rw-r--r--  1 pi pi   5107 Jan 10 17:22 Makefile
-rwxr-xr-x  1 pi pi  16104 Jan 10 17:24 mjpg_streamer
-rw-r--r--  1 pi pi  15738 Jan 10 17:22 mjpg_streamer.c
-rw-r--r--  1 pi pi   3617 Jan 10 17:22 mjpg_streamer.h
-rw-r--r--  1 pi pi   9800 Jan 10 17:24 mjpg_streamer.o
-rwxr-xr-x  1 pi pi  20284 Jan 10 17:24 output_file.so
-rwxr-xr-x  1 pi pi  32436 Jan 10 17:24 output_http.so
-rwxr-xr-x  1 pi pi  14891 Jan 10 17:24 output_udp.so
drwxr-xr-x 13 pi pi   4096 Jan 10 17:22 plugins
-rw-r--r--  1 pi pi   2631 Jan 10 17:22 README
drwxr-xr-x  2 pi pi   4096 Jan 10 17:22 scripts
-rwxr-xr-x  1 pi pi   4630 Jan 10 17:22 start.sh
-rw-r--r--  1 pi pi    285 Jan 10 17:22 TODO
-rw-r--r--  1 pi pi   2866 Jan 10 17:22 utils.c
-rw-r--r--  1 pi pi   2399 Jan 10 17:22 utils.h
-rw-r--r--  1 pi pi   1804 Jan 10 17:24 utils.o
drwxr-xr-x  2 pi pi   4096 Jan 10 17:22 www

You don't need a "sudo make install". Stay in current folder, the are all required binaries included.

test the mjpg_streamer and get the help

Code: [Select]
$ LD_LIBRARY_PATH=./ ./mjpg_streamer -i "input_file.so -h"
MJPG Streamer Version: svn rev: 3:172
 ---------------------------------------------------------------
 Help for input plugin..: FILE input plugin
 ---------------------------------------------------------------
 The following parameters can be passed to this plugin:

 [-d | --delay ]........: delay to pause between frames
 [-f | --folder ].......: folder to watch for new JPEG files
 [-r | --remove ].......: remove/delete JPEG file after reading
 [-n | --name ].........: ignore changes unless filename matches
 ---------------------------------------------------------------

$ LD_LIBRARY_PATH=./ ./mjpg_streamer -o "output_http.so -h"
MJPG Streamer Version: svn rev: 3:172
 ---------------------------------------------------------------
 Help for output plugin..: HTTP output plugin
 ---------------------------------------------------------------
 The following parameters can be passed to this plugin:

 [-w | --www ]...........: folder that contains webpages in
                           flat hierarchy (no subfolders)
 [-p | --port ]..........: TCP port for this HTTP server
 [-c | --credentials ]...: ask for "username:password" on connect
 [-n | --nocommands ]....: disable execution of commands
 ---------------------------------------------------------------

write a start script start1.sh (there is already a start.sh)
Code: [Select]
$ cat ./start1.sh
export LD_LIBRARY_PATH=./
./mjpg_streamer -i "input_file.so -f /mnt/RAMDisk/ -n thermal.jpg" -o "output_http.so -p 8080 -w /usr/local/www" &
./mjpg_streamer -i "input_file.so -d 250 -f /mnt/RAMDisk/ -n real.jpg"    -o "output_http.so -p 8081 -w /usr/local/www"

Please note, that I reduced with "-d 250"ms the frame rate of the visible image to 4 fps, to reduce the WLAN bandwidth

and start the script
Code: [Select]
$ ./start1.sh
MJPG Streamer Version: svn rev: 3:172M
 i: folder to watch...: /mnt/RAMDisk/
 i: forced delay......: 250
 i: delete file.......: no, do not delete
 i: filename must be..: real.jpg
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8081

MJPG Streamer Version: svn rev: 3:172M
 o: username:password.: disabled
 o: commands..........: enabled
 i: folder to watch...: /mnt/RAMDisk/
 i: forced delay......: 0
 i: delete file.......: no, do not delete
 i: filename must be..: thermal.jpg
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

now we have two MJPEG live streams

see the two web front ends for informations
Quote
http://192.168.1.70:8080
http://192.168.1.70:8081

test it with VLC or mplayer etc.
Code: [Select]
http://192.168.1.70:8080/?action=stream
http://192.168.1.70:8081/?action=stream

(7) a simple html web front end

create a index.html in your web folder /var/www
Code: [Select]
$ cat /var/www/index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
text-align:center;
background-color:#000000;
}
.container {
width:100%;
}
.motion1 {
border: 0;
width: 40%;
height: auto;
}
.motion2 {
border: 0;
width: 40%;
height: auto;
}
.clear {
clear:both;
}
</style>
</head>
<body>
<a href="http://192.168.1.70:8080"><img class="motion1" src="http://192.168.1.70:8080/?action=stream" /></a>

<a href="http://192.168.1.70:8081"><img class="motion2" src="http://192.168.1.70:8081/?action=stream" /></a>
</body>
</html>

load the site:
Code: [Select]
http://192.168.1.70
« Last Edit: December 06, 2016, 02:39:37 pm by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #134 on: January 10, 2016, 06:55:27 pm »
Hi tomas123,
Wow, you have been busy... :-+
Yea... Thermal Imaging section. :-+
Well I got my new kernel 4.3.3 for the pcduino building with buildroot, I was going to add the v4l2 kernel module, but after your recent experiments, maybe that's
not a good idea to waste any more time on.... I'd much rather a userland solution.

I'll try and replicate your system soon. Busy week ahead.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #135 on: January 10, 2016, 11:14:07 pm »
I'd much rather a userland solution.

I read something about the interesting UV4L "User space Video4Linux collection"
http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16
but I have no idea, how to implement this in our code.

The workaround over the RAMDisk has advantages and disadvantages.
mjpg-streamer waits patiently for the next jpg image.
Therefore you can restart the flir binary without stopping the mjpeg stream!  // edit: restart works with v4l2 driver also  ;)
Otherwise you have more random lags as with /dev/videoX.

For a surveillance camera with a low frame rate is the RAMDisk workaround acceptable.
If you want a nice live stream without lags, than is v4l2 the better solution.
 
The cutted source code flir8k contains a better error correction and a filter for FFC frames.
Code: [Select]
// freeze thermal image if "shutterState"="FFC"
  if (strncmp (&buf85[28+ThermalSize+JpgSize+17],"FFC",3)!=0)
  {

 
I added a nice restart sequence, because sometimes the code doesn't correct start the USB flir camera
Quote

$ sudo ./flir8k
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO
...
: Sun Jan 10 14:57:54 2016
 >>>>>>>>>>>>>>>>>bulk transfer (in) 0x81:-1 LIBUSB_ERROR_IO
EP 0x83 LIBUSB_ERROR_NO_DEVICE -> reset USB
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO

....
Write successful!
EP 0x02 to be sent: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}
Write successful!
Sent 65 bytes with string: {"type":"openFile","data":{"mode":"r","path":"CameraFiles.zip"}}

EP 0x02 to be sent Hexcode: 16 Bytes[ cc 01 00 00 01 00 00 00 33 00 00 00 ef db c1 c1 ]

Write successful!


« Last Edit: January 13, 2016, 10:01:49 pm by tomas123 »
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9938
  • Country: au
Re: Question about FLIR One for Android
« Reply #136 on: January 11, 2016, 02:30:00 am »
a subforum for "Thermal Imaging"  :-+ :-+

+1  :-+ :-+
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #137 on: January 11, 2016, 11:55:35 pm »
...
flir8i2.c (see attachment) writes all jpg frames for /dev/video2 and /dev/video3 to file
...
But still mjpg_streamer has the same problem with the mjpeg stream 160x120.
Code: [Select]
$ export LD_LIBRARY_PATH=/usr/local/lib

$ mjpg_streamer -i "input_uvc.so -d /dev/video3 -r 160x120" -o "output_http.so -w /usr/local/www"
MJPG Streamer Version: svn rev: Unversioned directory
 i: Using V4L2 device.: /dev/video3
 i: Desired Resolution: 160 x 120
 i: Frames Per Second.: 5
i: Format............: MJPEG
...
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
*** glibc detected *** mjpg_streamer: free(): invalid next size (normal): 0x01258910 ***
Aborted

Is 160x120 to small for mjpg_streamer?

I found a nice workaround for mjpg_streamer with the v4l2 input modul and 160x120 frame size.  :)

only enlarge the initialisation frame size of the v4l2 device from 160x120 to:
Code: [Select]
#define VIDEO_DEVICE2 "/dev/video3" // colorized thermal image
#define FRAME_WIDTH2  320
#define FRAME_HEIGHT2 240

than you can write a smaller jpeg of 160x120 to VIDEO_DEVICE2
Code: [Select]
  // write frame as jpg to fdwr2         
...
  int image_width=160; /* Number of columns in image */
  int image_height=120; /* Number of rows in image */
  int quality=90;

and mjpg_streamer works fine with v4l2 loopback device (also VLC etc.)

Code: [Select]
./mjpg_streamer -i "./input_uvc.so -d /dev/video2" -o "./output_http.so -p 8080 -w /usr/local/www" &
./mjpg_streamer -i "./input_uvc.so -d /dev/video3" -o "./output_http.so -p 8081 -w /usr/local/www"

 :palm:



Trying to get a new kernel built for my pcduino, and having some toolchain problems.

I know this point from my early cross compile experiences for embedded devices like router, NAS etc.
Last years I'm lazy and I mostly load a ready image for the raspberry pi.
Unfortunately currently there are no 100% corresponding kernel sources for the last raspberry pi image. It's a pain for compiling kernel drivers.   :-\
« Last Edit: January 12, 2016, 12:08:55 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #138 on: January 12, 2016, 01:57:34 am »
tomas123,
Been there done that.... Cross compiling kernel drivers is a PITA.....
I used to be better at it than I am now... been lazy lately too,  :palm:
Fixed the toolchain problems, cockpit problem again, kernel now compiling and running...
Then Linus releases 4.4 LTS so I need to repeat it all again with the new kernel code. |O

   ...ken...


 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #139 on: January 12, 2016, 08:43:51 am »
http://www.linksprite.com/linksprite-pcduino/

What are the advantages of the pcduino, which do you need versus a raspberry pi?
Flash?

for other readers: on the right side is a pcDuino3


« Last Edit: January 12, 2016, 08:48:45 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #140 on: January 12, 2016, 03:00:11 pm »
tomas123,
A bit off topic for the FlirOne Android thread but not tooooo far off.
I have several sbc's, and am always looking for a better "bang for the buck".
Prices keep falling and capabilities keep getting better.
I bought the pcduino3 nano lite just before Xmas, at $US15 delivered from Amazon.
Unfortunately that was some sort of promotion, and the real price is more like $US40. :(
So it is not as good a deal as first thought. Oh well... I'll buy one of almost any SBC if I think it's worth evaluating.
My collection of SBC's is like Frasers collection of thermal cameras (see not quite off topic :) )
It is still a nice board with fairly good kernel support.
I also have 2 RPi model B boards which I got in the early days of the RPi.
IMHO their USB core in the SOC stinks. Their USB power system on the board stinks.
This may have improved a bit in later versions RPi2.
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #141 on: January 12, 2016, 05:28:17 pm »
Hi cynfab,

I also have 2 RPi model B boards which I got in the early days of the RPi.
IMHO their USB core in the SOC stinks. Their USB power system on the board stinks.
This may have improved a bit in later versions RPi2.

I have also a "nice" collection of RPi A, RPi B and now RPi 2.
The USB power of RPi 2 is noticeable more better. We get no more low power resets after plug in a 300mA USB device.




I found a nice workaround for mjpg_streamer with the v4l2 input modul and 160x120 frame size.  :)

only enlarge the initialisation frame size of the v4l2 device from 160x120 to:
Code: [Select]
#define VIDEO_DEVICE2 "/dev/video3" // colorized thermal image
#define FRAME_WIDTH2  320
#define FRAME_HEIGHT2 240

as alternative for the RAMdisk version flir8k.c https://www.eevblog.com/forum/thermal-imaging/question-about-flir-one-for-android/msg839518/#msg839518

I uploaded as attachment the last version flir8k.c for v4l2 loopback devices with the better error correction, FFC filter etc.

Code: [Select]
$ make
gcc -I/usr/include/libusb-1.0    -c -o flir8l.o flir8l.c
gcc -I/usr/include/libusb-1.0 -o flir8l Palettes.o flir8l.o -lusb-1.0 -ljpeg -lm -Wall

$ sudo ./flir8l
Successfully find the Flir One G2 device
Successfully set usb configuration 3
Successfully claimed interface 0,1,2
using output device: /dev/video1
     vid_format->type                =2
     vid_format->fmt.pix.width       =160
     vid_format->fmt.pix.height      =120
     vid_format->fmt.pix.pixelformat =1497715271
     vid_format->fmt.pix.sizeimage   =20480
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=160
     vid_format->fmt.pix.colorspace  =8
using output device: /dev/video2
     vid_format->type                =2
     vid_format->fmt.pix.width       =640
     vid_format->fmt.pix.height      =480
     vid_format->fmt.pix.pixelformat =1196444237
     vid_format->fmt.pix.sizeimage   =1228800
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=0
     vid_format->fmt.pix.colorspace  =8
using output device: /dev/video3
     vid_format->type                =2
     vid_format->fmt.pix.width       =320
     vid_format->fmt.pix.height      =240
     vid_format->fmt.pix.pixelformat =1196444237
     vid_format->fmt.pix.sizeimage   =307200
     vid_format->fmt.pix.field       =1
     vid_format->fmt.pix.bytesperline=0
     vid_format->fmt.pix.colorspace  =8
stop interface 2 FRAME
stop interface 1 FILEIO

start interface 1 FILEIO
...

use second terminal to start twice mjpg-streamers
Code: [Select]
~/MJPG-Streamer/test/mjpg-streamer/mjpg-streamer $ cat ./start1.sh
./mjpg_streamer -i "./input_uvc.so -d /dev/video2" -o "./output_http.so -p 8080 -w /usr/local/www"&
./mjpg_streamer -i "./input_uvc.so -d /dev/video3" -o "./output_http.so -p 8081 -w /usr/local/www"

~/MJPG-Streamer/test/mjpg-streamer/mjpg-streamer $ ls
CHANGELOG      input_testpicture.so  LICENSE   mjpg_streamer    mjpg_streamer.h  output_file.so  output_udp.so  README   start1.sh  TODO     utils.h  www
input_file.so  input_uvc.so          Makefile  mjpg_streamer.c  mjpg_streamer.o  output_http.so  plugins        scripts  start.sh   utils.c  utils.o

~/MJPG-Streamer/test/mjpg-streamer/mjpg-streamer $ ./start1.sh
MJPG Streamer Version: svn rev: 3:172
 i: Using V4L2 device.: /dev/video2
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
 
MJPG Streamer Version: svn rev: 3:172
 i: Using V4L2 device.: /dev/video3
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 5
 i: Format............: MJPEG
 i: The format asked unavailable, so the width 320 height 240
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 8081
 o: username:password.: disabled
 o: commands..........: enabled

next step like here


now we have two MJPEG live streams

see the two web front ends for informations
Quote
http://192.168.1.70:8080
http://192.168.1.70:8081

test it with VLC or mplayer etc.
Code: [Select]
http://192.168.1.70:8080/?action=stream
http://192.168.1.70:8081/?action=stream

(7) a simple html web front end

create a index.html in your web folder /var/www
Code: [Select]
$ cat /var/www/index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
text-align:center;
background-color:#000000;
}
.container {
width:100%;
}
.motion1 {
border: 0;
width: 40%;
height: auto;
}
.motion2 {
border: 0;
width: 40%;
height: auto;
}
.clear {
clear:both;
}
</style>
</head>
<body>
<a href="http://192.168.1.70:8080"><img class="motion1" src="http://192.168.1.70:8080/?action=stream" /></a>

<a href="http://192.168.1.70:8081"><img class="motion2" src="http://192.168.1.70:8081/?action=stream" /></a>
</body>
</html>

load the site:
Code: [Select]
http://192.168.1.70
« Last Edit: January 13, 2016, 02:22:55 pm by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #142 on: January 16, 2016, 01:31:39 am »
Hi cynfab,

the next version for v4l2:
I extend the thermal image with 8 lines to 128x160 pixel.
Now is the height divisible by 16 (avoid video error: "not multiples of 16") and we have place for an information line.

With knowledge of the formulas in my excel sheet RAW2Temp.xls
(attachment of https://www.eevblog.com/forum/thermal-imaging/flir-e4-thermal-imaging-camera-teardown/msg342072/#msg342072)
I calculated the min/max temperature from the image and wrote some nice hot spot markers on the edges.
( thanks to tmbinc for the font.h the the code snippet  :-+ ,  see https://www.eevblog.com/forum/thermal-imaging/flir-ex-realtime-raw-radiometric-data-streaming-via-uvc/msg736344/#msg736344 )

For calculating the correct temperature you need the calibration values from your Flir One.
You can extract it from your CameraFiles.zip at EP 0x83, but more simply is to use an jpg image from the FlirOne.app and feed exiftool:
Code: [Select]
$ exiftool  -plan*  FLIROne-2015-11-30-17-26-48+0100.jpg
Planck R1                       : 16438.1
Planck B                        : 1416.5
Planck F                        : 1
Planck O                        : -1315
Planck R2                       : 0.0123569

and write it to the c source code
Code: [Select]
// -- define Flir calibration values ---------------
// exiftool -plan* FLIROne-2015-11-30-17-26-48+0100.jpg
#define  PlanckR1  16438.1
#define  PlanckB  1416.5
#define  PlanckF  1.0
#define  PlanckO  -1315.0
#define  PlanckR2  0.0123569
please note that I wrote always a decimal point, to avoid some unwanted integer castings in c

I wrote here dozens of post about the flir formulas, therefore only the code without comments:
Code: [Select]
double raw2temperature(unsigned short RAW)
{
 // mystery correction factor
 RAW *=4;
 // calc amount of radiance of reflected objects ( Emissivity < 1 )
 double RAWrefl=PlanckR1/(PlanckR2*(exp(PlanckB/(TempReflected+273.15))-PlanckF))-PlanckO;
 // get displayed object temp max/min
 double RAWobj=(RAW-(1-Emissivity)*RAWrefl)/Emissivity;
 // calc object temperature
 return PlanckB/log(PlanckR1/(PlanckR2*(RAWobj+PlanckO))+PlanckF)-273.15; 
}

There is a uncleared issue. With the FlirOne.App we get the correct Flir RAW values for the Excel Sheet above.
But over USB the RAW values seems divided by factor 4.
I'm unsure and will further check it with some temperature measurements.


Currently the string with min/max temperature is only for temperature below 100°C  because I forgot to truncate the strings to 20 chars   :o
« Last Edit: January 16, 2016, 01:55:08 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #143 on: January 16, 2016, 05:18:10 am »
Hi tomas123,
Nice :-+

I moved the plank constants to a header file so that the flir8xx.c code can be clean of individual F1 G2 characteristics.

Have you been able to view the video stream with guvcview, or mplayer?  .. see attached.
mplayer looks similar.

   ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #144 on: January 16, 2016, 11:46:54 am »
this is only a side effect of the mjpeg streamer workaround

I found a nice workaround for mjpg_streamer with the v4l2 input modul and 160x120 frame size.  :)

only enlarge the initialisation frame size of the v4l2 device from 160x120 to:
Code: [Select]
#define VIDEO_DEVICE2 "/dev/video3" // colorized thermal image
#define FRAME_WIDTH2  320
#define FRAME_HEIGHT2 240

than you can write a smaller jpeg of 160x120 to VIDEO_DEVICE2


the solution for guvcview or mplayer:

unload and reload the v4l2loopback kernel driver
Code: [Select]
// unload
$ sudo modprobe -r v4l2loopback
// load
$ sudo modprobe v4l2loopback devices=5

change code to the exact image size
Code: [Select]
#define VIDEO_DEVICE2 "/dev/video3" // colorized thermal image
#define FRAME_WIDTH2   160 //320
#define FRAME_HEIGHT2  128 //240

compile and guvcview / mplayer works fine




in all your screenshots I see, that your frame rate is around 8.2 fps
I have a later FlirOne hardware version. My frame rate ist mostly around 7.9fps  :(
Code: [Select]
#00007305 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.42668,"usbEnqueuedTimestamp":1177508916.4285,"ffcState":"FFC_VALID_RAD"}
#00007306 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.5428,"usbEnqueuedTimestamp":1177508916.54466,"ffcState":"FFC_VALID_RAD"}
#00007307 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.65624,"usbEnqueuedTimestamp":1177508916.65782,"ffcState":"FFC_VALID_RAD"}
#00007308 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.76904,"usbEnqueuedTimestamp":1177508916.77088,"ffcState":"FFC_VALID_RAD"}
#00007309 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.88276,"usbEnqueuedTimestamp":1177508916.88477,"ffcState":"FFC_VALID_RAD"}
#00007310 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508916.99627,"usbEnqueuedTimestamp":1177508916.99783,"ffcState":"FFC_VALID_RAD"}
#00007311 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.11095,"usbEnqueuedTimestamp":1177508917.11306,"ffcState":"FFC_VALID_RAD"}
#00007312 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.22461,"usbEnqueuedTimestamp":1177508917.22623,"ffcState":"FFC_VALID_RAD"}
#00007313 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.34107,"usbEnqueuedTimestamp":1177508917.3429,"ffcState":"FFC_VALID_RAD"}
#00007314 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.4537,"usbEnqueuedTimestamp":1177508917.45972,"ffcState":"FFC_VALID_RAD"}
#00007315 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.56661,"usbEnqueuedTimestamp":1177508917.56837,"ffcState":"FFC_VALID_RAD"}
#00007316 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.68063,"usbEnqueuedTimestamp":1177508917.6869,"ffcState":"FFC_VALID_RAD"}
#00007317 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.79463,"usbEnqueuedTimestamp":1177508917.79671,"ffcState":"FFC_VALID_RAD"}
#00007318 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508917.91498,"usbEnqueuedTimestamp":1177508917.91678,"ffcState":"FFC_VALID_RAD"}
#00007319 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.0219,"usbEnqueuedTimestamp":1177508918.02369,"ffcState":"FFC_VALID_RAD"}
#00007320 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.13852,"usbEnqueuedTimestamp":1177508918.14039,"ffcState":"FFC_VALID_RAD"}
#00007321 81/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.25196,"usbEnqueuedTimestamp":1177508918.25356,"ffcState":"FFC_VALID_RAD"}
#00007322 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.36496,"usbEnqueuedTimestamp":1177508918.3667,"ffcState":"FFC_VALID_RAD"}
#00007323 81/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.4781,"usbEnqueuedTimestamp":1177508918.48,"ffcState":"FFC_VALID_RAD"}
#00007324 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.59206,"usbEnqueuedTimestamp":1177508918.59365,"ffcState":"FFC_VALID_RAD"}
#00007325 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.70655,"usbEnqueuedTimestamp":1177508918.70863,"ffcState":"FFC_VALID_RAD"}
#00007326 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.82,"usbEnqueuedTimestamp":1177508918.82159,"ffcState":"FFC_VALID_RAD"}
#00007327 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508918.93411,"usbEnqueuedTimestamp":1177508918.93615,"ffcState":"FFC_VALID_RAD"}
#00007328 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.04937,"usbEnqueuedTimestamp":1177508919.05093,"ffcState":"FFC_VALID_RAD"}
#00007329 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.16221,"usbEnqueuedTimestamp":1177508919.16431,"ffcState":"FFC_VALID_RAD"}
#00007330 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.27651,"usbEnqueuedTimestamp":1177508919.28135,"ffcState":"FFC_VALID_RAD"}
#00007331 81/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.38965,"usbEnqueuedTimestamp":1177508919.39117,"ffcState":"FFC_VALID_RAD"}
#00007332 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.50482,"usbEnqueuedTimestamp":1177508919.50864,"ffcState":"FFC_VALID_RAD"}
#00007333 81/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.61759,"usbEnqueuedTimestamp":1177508919.61911,"ffcState":"FFC_VALID_RAD"}
#00007334 81/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.73212,"usbEnqueuedTimestamp":1177508919.73392,"ffcState":"FFC_VALID_RAD"}
#00007335 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.8459,"usbEnqueuedTimestamp":1177508919.84773,"ffcState":"FFC_VALID_RAD"}
#00007336 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508919.96018,"usbEnqueuedTimestamp":1177508919.96197,"ffcState":"FFC_VALID_RAD"}
#00007337 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.07373,"usbEnqueuedTimestamp":1177508920.07574,"ffcState":"FFC_VALID_RAD"}
#00007338 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.18741,"usbEnqueuedTimestamp":1177508920.18898,"ffcState":"FFC_VALID_RAD"}
#00007339 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.30213,"usbEnqueuedTimestamp":1177508920.30423,"ffcState":"FFC_VALID_RAD"}
#00007340 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.41558,"usbEnqueuedTimestamp":1177508920.41705,"ffcState":"FFC_VALID_RAD"}
#00007341 80/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.52954,"usbEnqueuedTimestamp":1177508920.53154,"ffcState":"FFC_VALID_RAD"}
#00007342 79/10 fps:{"shutterState":"ON","shutterTemperature":310.799987792969,"usbNotifiedTimestamp":1177508920.64426,"usbEnqueuedTimestamp":1177508920.6458,"ffcState":"FFC_VALID_RAD"}
« Last Edit: January 16, 2016, 11:56:27 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #145 on: January 17, 2016, 04:01:13 am »
Hi tomas123,

Your latest code is now cross compiled and running with mjpg-streamer on my pcduino3 nano lite. kernel 4.3.3
Wow, there are a lot of forks of mpg-streamer... close to 150!!
https://github.com/jacksonliam/mjpg-streamer   146 forks
https://github.com/oliv3r/mjpg-streamer    2 forks
and maybe more...

I'm getting 7.9-8.1 fps on the pcduino3.
And the occasional reset buffer because of bad Magic Byte.
The original 160 x 120 for video3 works with guvcview and mplayer.

  ...ken...
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #146 on: January 18, 2016, 08:05:37 am »
 :-+
if we debug the 160x120 resolution bug, than we can fork #151  :)

Code: [Select]
// mystery correction factor
 RAW *=4;

I checked it in my kitchen from -20°C to +100°C (boiling water). Tricky is to compare the temperature from our display (hottest point) with Flir crosshair (Flir One App) as medium of 4x4 pixel.
But it seems, that the correction factor works fine.
Please make own tests with your calibration values.

Maybe this is a effect of the conversion factor from 14 Bit (Sensor) to 16 Bit (2 Byte RAW)
« Last Edit: January 18, 2016, 11:26:06 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #147 on: January 18, 2016, 10:16:23 am »
I found a simple solution to check the factor 4 between "Lepton RAW" and "Flir radiometric jpg RAW":

The tea bag simulator of Flir SDK use real Lepton sensor values. You found it in the SDK file sampleframes.zip (6MB).
I made with the SDK App a shot from the (random) tea bag frame 00051.
Thereby we got a Flir radiometric jpg with an embedded calibrated RawThermalImage with a good temperature range from min/max=34°C/65°C ;)
(the unrealistic min temperature is a result of bad calibration values for the simulator)

first some image magick steps with the lepton sensor values of frame 00051 (file 00051-lep) from SDK sampleframes.zip
("-chop 2x0+0+0 -chop 2x0+80+0" removes the 4 additional vertical lines with extra unknown informations)
Code: [Select]
// convert sample frame 00051 from SDK
> convert -depth 16 -size 164x120 gray:00051-lep gray:- | convert -depth 16 -endian lsb -size 164x120 gray:- -chop 2x0+0+0 -chop 2x0+80+0 -rotate 90 00051-lep.png
// multiply with factor 4
> convert 00051-lep.png -fx "4*u" 00051-lep4x.png
// get channel statistics
> identify -verbose 00051-lep4x.png
  Channel statistics:
    Pixels: 19200
    Gray:
      min: 14220 (0.216983)
      max: 20840 (0.317998)
      mean: 15014.9 (0.229113)
      standard deviation: 1218.95 (0.0186)
      kurtosis: 5.54453
      skewness: 2.30479

and now compare the statistics with the "real" Flir radiometric image from the SDK app
Code: [Select]
// extract RawThermalImage from a Flir radiometric image
> exiftool -b -RawThermalImage FLIROne-2016-01-18-10-33-07+0100.jpg > 00051exif.png
// image is postprocessed and resized to 320x240
> convert 00051exif.png -resize 160x FlirAppRAW120x160.png
// get channel statistics
>identify -verbose FlirAppRAW120x160.png
...
  Channel statistics:
    Pixels: 19200
    Gray:
      min: 14266 (0.217685)
      max: 20831 (0.317861)
      mean: 15021.4 (0.229212)
      standard deviation: 1221.27 (0.0186354)
      kurtosis: 5.44004
      skewness: 2.28451

By deducting the Flir post processing steps to the original RAW values (see patterns below) we got a great result!
A sample:

max-min=65-34=31°C
max-min=20831-14266=6565 digits
-> 1 digit = 31/6565=0.0047 Kelvin
The difference between mean in this images is:
(15021.4-15014.9)*0.0047 Kelvin= 0.031 Kelvin
  :-+

You also see, that the last digit ADC "resolution" of Lepton in this range is > 0.0047*4 = 19mK (useless because of strong noise, see second image below with 4 Kelvin scale)

here is a real live sample from Flir One G2 (shot after a small warm up time of about 2 minutes):

I saved with the SDK.app simultaneously a upscaled Flir Radiometric JPG  and a real Lepton ThermalLinearFlux14BitImage.

Afterwards I rebuild with my old panorama script (see my footer) a real size 160x120 Lepton radiometric jpg (a Flir format).
You can load this sample jpg images in Flir Tools and compare the quality.


First a original image shot with the Flir App.
The App crop  >:(  the Lepton sensor to about 120x90 Pixel.
Please note the artefacts/patterns!
Flir makes a nice lens distortion correction of the Lepton sensor for best MSX overlaying  ;)





real  Lepton sensor 160x120 (no image postprocessing and with noise/grain because the temperature spread is only 4 Kelvin)


« Last Edit: January 18, 2016, 11:24:13 am by tomas123 »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #148 on: January 19, 2016, 11:26:11 pm »
minor update:

- a smaller font 5x7 for more chars in information line
- better filtering FFC frames
- crosshair for medium temperature of 2x2 "center" pixels
- info line with temperature  min/crosshair/max

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #149 on: January 20, 2016, 12:10:48 am »
tomas123,

Very nice :-+
 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #150 on: January 20, 2016, 03:19:27 am »
Looking very good. Excellent work. 👍
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #151 on: January 20, 2016, 08:53:05 am »
Thank You!

Unfortunately we are only two F1G2 hackers  :(

The internet is full with crazy projects using a Lepton 60x80.

https://store.groupgets.com/#!/p/52239877
- $210 FLIR Lepton Dev Kit
- with Raspberry Pi 2 Model B and a Raspberry Pi 5 MP Camera Board
- Requires FLIR Lepton (sold separately)

  :-DD



And don't forget, the Flir One is the only Lepton module with (calibrated) temperature measurement
http://www.flir.com/cvs/cores/knowledgebase/index.cfm?CFTREEITEMKEY=914&view=67485
« Last Edit: January 20, 2016, 08:59:27 am by tomas123 »
 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #152 on: January 20, 2016, 05:59:38 pm »
Yes it is a pity that there are not more people working on F1G2 development. Sadly my skill set does not include coding and the LEPTON 3 hardware is pretty well formed for many tasks. When I find time I will make a close up lens holder for the unit that will utilise a 12mm ZnSe lens. Sadly the MSX tends to be detrimental to close up performance even if the visible light camera is blinded.

I appreciate your work and efforts though. I thought the other day that the F1G2 has not made the splash that I had expected. When compared to the SEEK camera release, the FLIR F1G2 has received a very muted response for no reason that I can identify. It is certainly selling well as FLIR continue to have trouble meeting demand. Maybe the Budget thermal camera is old news now and of less interest to the forum membership ?

Fraser
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #153 on: January 20, 2016, 09:12:38 pm »
Sadly the MSX tends to be detrimental to close up performance even if the visible light camera is blinded.

try the SDK apk, there you can disable MSX
I uploaded the self compiled SDK app for Android.
Try the "Thermal Linear Flux 14 Bit Image" mode:

http://www.file-upload.net/download-11032220/FlirOneSDK.apk.html


Maybe the Budget thermal camera is old news now and of less interest to the forum membership ?
I think also. Furthermore most retailer can't deliver Flir One G2 for Android.
We have a delay of 6 weeks in Europe.

Offline Trax

  • Regular Contributor
  • *
  • Posts: 119
  • Country: at
Re: Question about FLIR One for Android
« Reply #154 on: January 30, 2016, 06:52:47 pm »
what hardware are you connecting the F2G2 to?
Is it running some plain Linux or an android firmware?
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #155 on: January 30, 2016, 07:17:11 pm »
Both tomas123 and I have the F1G2 running under linux (various distros) on x86 and ARM hardware.
RPi2, pcduino nano lite, Dell i7 desktop, hardkernel XU4, Amazon Fire 2015 tablet, Motorola Moto E, Google Nexus 7 2012
We also have each built Android apps from the FlirOne SDK.
« Last Edit: January 30, 2016, 07:19:50 pm by cynfab »
 

Offline Trax

  • Regular Contributor
  • *
  • Posts: 119
  • Country: at
Re: Question about FLIR One for Android
« Reply #156 on: January 30, 2016, 07:26:59 pm »
is the howto and source code organized in some place or do one need to scavenge the whole thread for bits and pieces?

F1G2 on a x86 tablet would be awesome for me :D
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #157 on: January 30, 2016, 08:32:53 pm »
It's all in this thread.
 


Offline Trax

  • Regular Contributor
  • *
  • Posts: 119
  • Country: at
Re: Question about FLIR One for Android
« Reply #159 on: February 03, 2016, 06:58:44 pm »
I read in another thread that flir is deliberetly degrading the quality of teh f1g2 images, is that solved by the custom software or is it done in firmware ?
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #160 on: February 03, 2016, 10:10:19 pm »
The camera sends over USB full resolution images.
"Downgrade" or MSX works in user software.
With free SDK you also can process 160x120 images.

Offline in.Vitro

  • Contributor
  • Posts: 46
  • Country: de
Re: Question about FLIR One for Android
« Reply #161 on: February 10, 2016, 11:23:05 am »
i have a dumb question... is there any way to get any data from the micro USB port or is just for charging? has anyone "backtraced" the USB port?
 

Offline frenky

  • Supporter
  • ****
  • Posts: 971
  • Country: si
    • Frenki.net
Re: Question about FLIR One for Android
« Reply #162 on: February 10, 2016, 11:33:45 am »
It looks like only the Vcc pin is connected to bottom layer... (and ground of course)



http://hardtechlife.com/teardown-flir-one-for-android/
« Last Edit: February 10, 2016, 11:38:25 am by frenky »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #163 on: February 11, 2016, 06:59:00 am »
I think also, but it's a multi layer circuit board. Therefore I can't see any details on this images.
 
Sharper images from disassembly you find here:
https://www.eevblog.com/forum/thermal-imaging/new-flir-products/msg750181/#msg750181
     
« Last Edit: February 11, 2016, 07:06:11 am by tomas123 »
 

Offline cynfab

  • Regular Contributor
  • *
  • Posts: 150
Re: Question about FLIR One for Android
« Reply #164 on: February 12, 2016, 03:45:23 am »
I'm pretty sure I rang out the D+ & D- lines on the charging connector and they don't go anywhere.
But, you can charge the camera while operating. The charging messages tell you the state.
I have had some wierd things happen if left on charge too long. The power button turns red and flashes. I haven't seen any description of what that
means but I can guess it is not good.
I'd bet is one of the bad ones below, probably FAULT_HEAT.

From the SDK docs:

BAD
Indicates that a valid battery charging state was not available.
CHARGING_SMART_PHONE_FAULT_HEAT
Indicates that a charging fault exists but the iPhone is being charged
CHARGING_SMART_PHONE_ONLY
Indicates that the device is in phone-charging-only mode
FAULT
Indicates that an unexpected charging fault occurred (bad battery, etc.)
FAULT_BAD_CHARGER
Indicates that a charging fault occurred due to low current from the charging source
FAULT_HEAT
Indicates that a charging heat fault occurred
MANAGED_CHARGING
Indicates that the battery is charging from external power.
MANAGED_CHARGING_ONLY
Indicates that the device is in charge-only mode
NO_CHARGING
Indicates that the battery is not charging because the device is not connected to an external power supply.

 

Offline nitroxide

  • Contributor
  • Posts: 26
Re: Question about FLIR One for Android
« Reply #165 on: March 12, 2016, 03:37:30 am »
Tomas123, you rock! Great work.

If you (or others) feel like customising the F1G2 software as well:

      As you may well know already there's a UART interface (3.3V level; 3 pads on the corner of SoC - GND RX TX) on the F1G2 PCB that allows serial console access to the Linux running on the SoC.
     However it's password protected and simple bootargs tricks from uboot would not work (bootargs env. variables are simply ignored).

     I've dumped the NAND from uboot and done some poking around with binwalk and recovered the root password.

     If anyone wants to check it out login with (root:indigo):

Code: [Select]
U-Boot> run boot_op
boot operational

Loading from nand0, offset 0xe00000
   Image Name:   Linux-2.6.39+
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3358884 Bytes = 3.2 MiB
   Load Address: 20008000
   Entry Point:  20008000
Automatic boot of image at addr 0x22000000 ...
## Booting kernel from Legacy Image at 22000000 ...
   Image Name:   Linux-2.6.39+
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3358884 Bytes = 3.2 MiB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.025000] AT91: CM rev B and higher
[    0.037000] AT91: EK rev B and higher
[    0.401000] AT91SAM9 Watchdog: sorry, watchdog is disabled
Starting watchdog...done
mounting jffs2 READ-ONLY...done
start battery charge control
Starting battery_charge: OK
done
Formatting /tmp/versions: OK
[    1.677000] lepton_init
[    1.685000] lepton_probe: using 16-bit SPI width

Welcome to Rosebud (Operational)
(none) login: root
Password:
login[315]: root login on 'ttyS0'
-sh: id: not found
sh: bad number
-sh: id: not found
-sh: /bin/hostname: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
-sh: alias: not found
$ cd /
$ ls
bin          home         linuxrc      proc         sys          var
dev          init         mnt          root         tmp          version.txt
etc          lib          opt          sbin         usr
$ cd /
$ uname -a
Linux (none) 2.6.39+ #5 Fri Sep 4 16:01:23 PDT 2015 armv5tejl GNU/Linux

Cheers!
Nitro
 

Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #166 on: March 12, 2016, 11:23:52 am »
@Nitroxide,

Nice work. The name  'Rosebud' has been seen before in FLIR cameras. The password on many FLIR cameras was a Swedish word but 'Indigo' is a nod to the company, Indigo Systems that FLIR bought in 2003.

Indigo Systems were a specialist in compact thermal cameras and experts in microbolometers, image processing and novel camera design. FLIR wanted that specialist knowledge, so bought them.

http://www.flir.com/corporate/display/?id=55679

Fraser
« Last Edit: March 12, 2016, 11:28:49 am by Fraser »
 

Offline nitroxide

  • Contributor
  • Posts: 26
Re: Question about FLIR One for Android
« Reply #167 on: March 12, 2016, 11:36:39 am »
@Fraser Yep, definitely not without reason

In case anyone was curious, here's a dmesg output:

Code: [Select]
$ dmesg
[    0.000000] Linux version 2.6.39+ (nightly@rosebud-dev) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #5 Fri Sep 4 16:01:23 PDT 2015
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] Machine: Atmel AT91SAM9X5-EK
[    0.000000] Ignoring tag cmdline (using the default kernel command line)
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] Clocks: CPU 400 MHz, master 133 MHz, main 12.000 MHz
[    0.000000] On node 0 totalpages: 16384
[    0.000000] free_area_init_node: node 0, pgdat c071ada8, node_mem_map c0729000
[    0.000000]   Normal zone: 128 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 16256 pages, LIFO batch:3
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: mem=64M mtdparts=atmel_nand:50M(rosebud),14M(shared_files),12M(kernel),37M(rootfs),14M(shared_files2) rw atmel_nand.use_dma=0 quiet
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 64MB = 64MB total
[    0.000000] Memory: 57600k/57600k available, 7936k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xff000000 - 0xffe00000   (  14 MB)
[    0.000000]     vmalloc : 0xc4800000 - 0xfee00000   ( 934 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .init : 0xc0008000 - 0xc0482000   (4584 kB)
[    0.000000]       .text : 0xc0482000 - 0xc06fe508   (2546 kB)
[    0.000000]       .data : 0xc0700000 - 0xc071b4a0   ( 110 kB)
[    0.000000] NR_IRQS:192
[    0.000000] AT91: 128 gpio irqs in 4 banks
[    0.000000] AT91: Disabled rtc irq
[    0.000000] console [ttyS0] enabled
[    0.000000] Calibrating delay loop... 197.88 BogoMIPS (lpj=98944)
[    0.011000] pid_max: default: 32768 minimum: 301
[    0.011000] Mount-cache hash table entries: 512
[    0.012000] CPU: Testing write buffer coherency: ok
[    0.019000] NET: Registered protocol family 16
[    0.025000] AT91: CM rev B and higher
[    0.029000] AT91: Configured PCK0 clock output to 25000000 Hz
[    0.029000] BT: PCK0 on PB10 = 74
[    0.037000] BT: gpios initialized
[    0.037000] AT91: pin-mux CS0
[    0.037000] AT91: pin-mux CS2
[    0.037000] AT91: EK rev B and higher
[    0.044000] AT91: Power Management (with slow clock mode)
[    0.044000] AT91: Starting after general reset
[    0.045000] tcb_clksrc: tc0 at 16.166 MHz
[    0.068000] bio: create slab <bio-0> at 0
[    0.070000] usbcore: registered new interface driver usbfs
[    0.071000] usbcore: registered new interface driver hub
[    0.072000] usbcore: registered new device driver usb
[    0.075000] i2c-gpio i2c-gpio.0: using pins 62 (SDA) and 63 (SCL)
[    0.075000] at_hdmac at_hdmac.0: Atmel AHB DMA Controller ( cpy slave ), 8 channels
[    0.080000] at_hdmac at_hdmac.1: Atmel AHB DMA Controller ( cpy slave ), 8 channels
[    0.086000] Switching to clocksource tcb_clksrc
[    0.092000] NET: Registered protocol family 1
[    0.206000] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.206000] msgmni has been set to 112
[    0.207000] io scheduler noop registered (default)
[    0.217000] atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
[    0.224000] brd: module loaded
[    0.236000] atmel_nand atmel_nand: No DMA support for NAND access.
[    0.236000] ONFI flash detected
[    0.237000] ONFI param page 0 valid
[    0.237000] NAND device: Manufacturer ID: 0x2c, Chip ID: 0xa1 (Micron MT29F1G08ABBEA3W)
[    0.237000] atmel_pmecc_init_params
[    0.237000] nand_chip->ecc.bytes 28
[    0.237000] nand_chip->ecc.steps 1
[    0.237000] nand_chip->ecc.layout = pmecc_oobinfo_2048
[    0.237000] host->mm 13
[    0.237000] host->nn 8191
[    0.237000] host->tt 4
[    0.237000] host->sector_size 512
[    0.237000] host->sector_number 4
[    0.237000] host->ecc_bytes_per_sector 7
[    0.237000] host->alpha_to -996098048
[    0.237000] host->index_of -996114432
[    0.237000] Scanning device for bad blocks
[    0.297000] 5 cmdlinepart partitions found on MTD device atmel_nand
[    0.297000] Creating 5 MTD partitions on "atmel_nand":
[    0.297000] 0x000000000000-0x000003200000 : "rosebud"
[    0.301000] 0x000003200000-0x000004000000 : "shared_files"
[    0.304000] 0x000004000000-0x000004c00000 : "kernel"
[    0.307000] 0x000004c00000-0x000007100000 : "rootfs"
[    0.311000] 0x000007100000-0x000007f00000 : "shared_files2"
[    0.316000] SPI MR: 0x33
[    0.317000] atmel_spi atmel_spi.0: Using dma0chan0 (tx) and  dma0chan1 (rx) for DMA transfers
[    0.317000] atmel_spi atmel_spi.0: Atmel SPI Controller at 0xf0000000 (irq 13, SR 0x00010202)
[    0.317000] SPI turning on CSAAT
[    0.318000] setup: 22222222 Hz bpw 8 mode 0x3 -> csr0 00000609
[    0.319000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.319000] ehci_hcd: block sizes: qh 60 qtd 96 itd 160 sitd 96
[    0.319000] Initializing Atmel-SoC USB Host Controller
[    0.319000] atmel-ehci atmel-ehci: start
[    0.320000] atmel-ehci atmel-ehci: Atmel EHCI UHP HS
[    0.320000] atmel-ehci atmel-ehci: new USB bus registered, assigned bus number 1
[    0.320000] atmel-ehci atmel-ehci: reset hcs_params 0x1303 dbg=0 cc=1 pcc=3 ordered !ppc ports=3
[    0.320000] atmel-ehci atmel-ehci: reset hcc_params 0026 thresh 2 uframes 256/512/1024 park
[    0.320000] atmel-ehci atmel-ehci: park 0
[    0.320000] atmel-ehci atmel-ehci: reset command 0080b02  park=3 ithresh=8 period=1024 Reset HALT
[    0.320000] atmel-ehci atmel-ehci: irq 22, io mem 0x00700000
[    0.320000] atmel-ehci atmel-ehci: reset command 0080b02  park=3 ithresh=8 period=1024 Reset HALT
[    0.321000] atmel-ehci atmel-ehci: init command 0010005 (park)=0 ithresh=1 period=512 RUN
[    0.327000] atmel-ehci atmel-ehci: USB 2.0 started, EHCI 1.00
[    0.327000] usb usb1: default language 0x0409
[    0.327000] usb usb1: udev 1, busnum 1, minor = 0
[    0.327000] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    0.327000] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.327000] usb usb1: Product: Atmel EHCI UHP HS
[    0.327000] usb usb1: Manufacturer: Linux 2.6.39+ ehci_hcd
[    0.327000] usb usb1: SerialNumber: atmel-ehci
[    0.328000] usb usb1: usb_probe_device
[    0.328000] usb usb1: configuration #1 chosen from 1 choice
[    0.328000] usb usb1: adding 1-0:1.0 (config #1, interface 0)
[    0.329000] hub 1-0:1.0: usb_probe_interface
[    0.329000] hub 1-0:1.0: usb_probe_interface - got id
[    0.329000] hub 1-0:1.0: USB hub found
[    0.329000] hub 1-0:1.0: 3 ports detected
[    0.329000] hub 1-0:1.0: standalone hub
[    0.329000] hub 1-0:1.0: no power switching (usb 1.0)
[    0.329000] hub 1-0:1.0: individual port over-current protection
[    0.329000] hub 1-0:1.0: power on to power good time: 20ms
[    0.329000] hub 1-0:1.0: local power source is good
[    0.330000] hub 1-0:1.0: trying to enable port power on non-switchable hub
[    0.331000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.331000] ohci_hcd: block sizes: ed 64 td 64
[    0.332000] at91_ohci at91_ohci: start
[    0.332000] at91_ohci at91_ohci: AT91 OHCI
[    0.332000] at91_ohci at91_ohci: new USB bus registered, assigned bus number 2
[    0.332000] at91_ohci at91_ohci: supports USB remote wakeup
[    0.332000] at91_ohci at91_ohci: irq 22, io mem 0x00600000
[    0.332000] at91_ohci at91_ohci: created debug files
[    0.387000] at91_ohci at91_ohci: OHCI controller state
[    0.387000] at91_ohci at91_ohci: OHCI 1.0, NO legacy support registers
[    0.387000] at91_ohci at91_ohci: control 0x083 HCFS=operational CBSR=3
[    0.387000] at91_ohci at91_ohci: cmdstatus 0x00000 SOC=0
[    0.387000] at91_ohci at91_ohci: intrstatus 0x00000004 SF
[    0.387000] at91_ohci at91_ohci: intrenable 0x8000005a MIE RHSC UE RD WDH
[    0.387000] at91_ohci at91_ohci: hcca frame #0005
[    0.387000] at91_ohci at91_ohci: roothub.a 02000203 POTPGT=2 NPS NDP=3(3)
[    0.387000] at91_ohci at91_ohci: roothub.b 00000000 PPCM=0000 DR=0000
[    0.387000] at91_ohci at91_ohci: roothub.status 00008000 DRWE
[    0.387000] at91_ohci at91_ohci: roothub.portstatus [0] 0x00000100 PPS
[    0.387000] at91_ohci at91_ohci: roothub.portstatus [1] 0x00000100 PPS
[    0.387000] at91_ohci at91_ohci: roothub.portstatus [2] 0x00000100 PPS
[    0.387000] usb usb2: default language 0x0409
[    0.387000] usb usb2: udev 1, busnum 2, minor = 128
[    0.387000] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001
[    0.387000] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.387000] usb usb2: Product: AT91 OHCI
[    0.387000] usb usb2: Manufacturer: Linux 2.6.39+ ohci_hcd
[    0.387000] usb usb2: SerialNumber: at91
[    0.389000] usb usb2: usb_probe_device
[    0.389000] usb usb2: configuration #1 chosen from 1 choice
[    0.389000] usb usb2: adding 2-0:1.0 (config #1, interface 0)
[    0.390000] hub 2-0:1.0: usb_probe_interface
[    0.390000] hub 2-0:1.0: usb_probe_interface - got id
[    0.390000] hub 2-0:1.0: USB hub found
[    0.390000] hub 2-0:1.0: 3 ports detected
[    0.390000] hub 2-0:1.0: standalone hub
[    0.390000] hub 2-0:1.0: no power switching (usb 1.0)
[    0.390000] hub 2-0:1.0: global over-current protection
[    0.390000] hub 2-0:1.0: power on to power good time: 4ms
[    0.390000] hub 2-0:1.0: local power source is good
[    0.390000] hub 2-0:1.0: no over-current condition exists
[    0.390000] hub 2-0:1.0: trying to enable port power on non-switchable hub
[    0.392000] atmel_usba_udc atmel_usba_udc: MMIO registers at 0xf803c000 mapped at c4876000
[    0.392000] atmel_usba_udc atmel_usba_udc: FIFO at 0x00500000 mapped at c4900000
[    0.393000] gadgetfs: USB Gadget filesystem, version 24 Aug 2004
[    0.394000] at91_rtc at91_rtc: rtc core: registered at91_rtc as rtc0
[    0.394000] AT91 Real Time Clock driver.
[    0.394000] i2c /dev entries driver
[    0.395000] Linux media interface: v0.10
[    0.396000] Linux video capture interface: v2.00
[    0.401000] usbcore: registered new interface driver uvcvideo
[    0.402000] USB Video Class driver (v1.0.0)
[    0.402000] AT91SAM9 Watchdog: sorry, watchdog is disabled
[    0.407000] at91_wdt: probe of at91_wdt failed with error -5
[    0.410000] at91_rtc at91_rtc: setting system clock to 2007-01-01 00:00:17 UTC (1167609617)
[    0.413000] Freeing init memory: 4584K
[    0.430000] atmel-ehci atmel-ehci: GetStatus port:2 status 001803 0  ACK POWER sig=j CSC CONNECT
[    0.430000] hub 1-0:1.0: port 2: status 0501 change 0001
[    0.490000] hub 2-0:1.0: state 7 ports 3 chg 0000 evt 0000
[    0.530000] hub 1-0:1.0: state 7 ports 3 chg 0004 evt 0000
[    0.530000] hub 1-0:1.0: port 2, status 0501, change 0000, 480 Mb/s
[    0.555000] Empty flash at 0x000001b0 ends at 0x00000800
[    0.581000] atmel-ehci atmel-ehci: port 2 high speed
[    0.581000] atmel-ehci atmel-ehci: GetStatus port:2 status 001005 0  ACK POWER sig=se0 PE CONNECT
[    0.632000] usb 1-2: new high speed USB device number 2 using atmel-ehci
[    0.680000] Major: 252; minor: 0
[    0.680000] Registered device at91_adc.
[    0.684000] atmel-ehci atmel-ehci: port 2 high speed
[    0.684000] atmel-ehci atmel-ehci: GetStatus port:2 status 001005 0  ACK POWER sig=se0 PE CONNECT
[    0.788000] usb 1-2: skipped 1 descriptor after configuration
[    0.788000] usb 1-2: skipped 6 descriptors after interface
[    0.788000] usb 1-2: skipped 1 descriptor after endpoint
[    0.788000] usb 1-2: skipped 9 descriptors after interface
[    0.789000] usb 1-2: default language 0x0409
[    0.795000] usb 1-2: udev 2, busnum 1, minor = 1
[    0.795000] usb 1-2: New USB device found, idVendor=0c45, idProduct=6369
[    0.795000] usb 1-2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[    0.795000] usb 1-2: Product: USB 2.0 Camera
[    0.795000] usb 1-2: Manufacturer: Sonix Technology Co., Ltd.
[    0.802000] usb 1-2: usb_probe_device
[    0.802000] usb 1-2: configuration #1 chosen from 1 choice
[    0.802000] usb 1-2: adding 1-2:1.0 (config #1, interface 0)
[    0.807000] uvcvideo 1-2:1.0: usb_probe_interface
[    0.807000] uvcvideo 1-2:1.0: usb_probe_interface - got id
[    0.807000] uvcvideo: Found UVC 1.00 device USB 2.0 Camera (0c45:6369)
[    0.842000] usb 1-2: adding 1-2:1.1 (config #1, interface 1)
[    1.454000] at91_ohci at91_ohci: auto-stop root hub
[    1.594000] usb 1-2: link qh4-0001/c32407a0 start 1 [1/0 us]
[    1.695000] lepton_init
[    1.698000] tx_buf = c3328000 rx_buf = c3330000, frames = bf006f74
[    1.703000] lepton_probe: using 16-bit SPI width
[    1.708000] SPI turning on CSAAT
[    1.708000] setup: 22222222 Hz bpw 16 mode 0x3 -> csr0 00000689
[    1.714000] VSYNC [4294669010]
[    1.718000] lepton: bad line index, last line index 255 != expected index 60
[    1.718000] lepton status = 3 xfer 4 [4294669014]
[    8.156000] usb 1-2: unlink qh4-0001/c32407a0 start 1 [1/0 us]
[    8.156000] atmel-ehci atmel-ehci: shutdown urb c320cac0 ep3in-intr
$
 

Offline Bill W

  • Frequent Contributor
  • **
  • Posts: 480
  • Country: gb
    • Fire TICS
Re: Question about FLIR One for Android
« Reply #168 on: March 12, 2016, 05:44:43 pm »
I wonder how many folks from Indigo are now with SEEK ?  Far too much of a coincidence I reckon.

Fired up an old Indigo Alpha core the other day, surprisingly poor for a VOx with a lot of column structure, how far they have come.  Even then it was very compact though.  The oddest feature of that was the external shutter.
A 2005 paper about early VOX bolometers :
http://www.flir.com/uploadedFiles/CBI/Documents/Technical_Publications/2005SPIE/techpub_2_Photon_SPIE_2005.pdf
It must be early, they were still being honest about NETD's  >:D

Bill

www.fire-tics.co.uk



Offline Fraser

  • Super Contributor
  • ***
  • Posts: 9307
  • Country: gb
Re: Question about FLIR One for Android
« Reply #169 on: March 12, 2016, 08:10:23 pm »
FLIR were certainly annoyed when the two ex Indigo staff started SEEK Thermal. A complex situation that ended in court.

I was always interested that FLIR enforced disablement of every 15th pixel on the SEEK 12um microbolometer. At the time I suspected the FLIR & SEEK 12um microbolometers were likely the product of a single research work  stream within FLIR.

Fraser
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #170 on: March 13, 2016, 01:13:56 pm »
     I've dumped the NAND from uboot and done some poking around with binwalk and recovered the root password.

     If anyone wants to check it out login with (root:indigo):

interesting :-+
In the Flir One SDK library I can't find the strings root:indigo.
There is only the well known Flir login root:3vlig
Code: [Select]
$ strings FLIRONEExampleApplication/app/src/main/libs/armeabi-v7a/libjnidevicewrapper.so  | grep -Fx -A1 root
root
3vlig

In the FlirOneApp the functions of the "SDK library libjnidevicewrapper.so" is splittet in a libjnidevicewrapper.so and a libsystemimage.so.
The FlirOneApp handles also the firmware updates of the Flir One.
Code: [Select]
$ strings FlirOne/apk/FlirOne/lib/armeabi-v7a/libsystemimage.so | grep -Fx -A1 root
root
3vlig

Offline nitroxide

  • Contributor
  • Posts: 26
Re: Question about FLIR One for Android
« Reply #171 on: March 13, 2016, 06:50:07 pm »
@tomas123 Could be something left out in their SDK? I don't think the smartphones handling the updates do any logging in on the F1G2..

There's a separate kernel image for the updater but I've checked now with 3vlig and the password for that one is indigo as well.
Fun fact: the indigo password was hashed but unsalted so it only took John the Ripper a few seconds to crack :)

I may do a dump of all folders from both images if I get some time next week but that'll need some fiddling around with serial file transfer.

Nitro
 

Offline eren

  • Newbie
  • Posts: 4
  • Country: tr
Re: Question about FLIR One for Android
« Reply #172 on: March 15, 2016, 05:41:49 pm »
Hi all,

amazing work on this thread! I am continually blown away by the casually colossal magnitude of work done here  :-+   

I'm just catching up with the capabilities, and running the F1 on Raspbian. Every once in a while I'm getting these stretches of rainbow frames where the FFC apparently gets in a bad state, and I have to wait until the next automatic FFC to clear it up. There is nothing coming from the 0x81, 0x83 or 0x85 endpoints to indicate we're entering a bad state. I'd like to try inducing an FFC state, at first periodically, any maybe later when I detect this state by pixel standard deviation etc. I can see manual FFC commands in the SDK, but no way to do that manually using libusb. Anybody have any ideas on how to manually trigger FFC by writing to USB endpoints?

Cheers
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #173 on: March 16, 2016, 09:48:53 pm »
There is nothing coming from the 0x81, 0x83 or 0x85 endpoints to indicate we're entering a bad state.
The stretches of of rainbow frames are reflections of the temperature of warm lepton on the shutter ;)
I wrote here something about trigger the FFC:
...The blue line is the average temperature of 2x2=4 center pixels. The measured temperature was a wall with a constant temperature over the hour.
The F1 G2 needs 10 minutes until stabilization.
The vertical green lines mark the FFC shutter movements.

The shutter interval is constant 135 seconds after 5 minutes runtime.

watch for combination of "shutterState" AND "ffcState" on EP 0x85
Code: [Select]
#000373 77/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.09764,"usbEnqueuedTimestamp":1176999451.09942,"ffcState":"FFC_VALID_RAD"}
#000374 77/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.2123,"usbEnqueuedTimestamp":1176999451.21411,"ffcState":"FFC_VALID_RAD"}
#000375 78/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.32683,"usbEnqueuedTimestamp":1176999451.32872,"ffcState":"FFC_VALID_RAD"}
#000376 78/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.43988,"usbEnqueuedTimestamp":1176999451.44173,"ffcState":"FFC_VALID_RAD"}
#000377 78/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.55378,"usbEnqueuedTimestamp":1176999451.55576,"ffcState":"FFC_VALID_IMG"}
#000378 78/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.66878,"usbEnqueuedTimestamp":1176999451.67105,"ffcState":"FFC_VALID_IMG"}
#000379 78/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.7818,"usbEnqueuedTimestamp":1176999451.78388,"ffcState":"FFC_DESIRED"}
#000380 79/10 fps:{"shutterState":"ON","shutterTemperature":310.040008544922,"usbNotifiedTimestamp":1176999451.8954,"usbEnqueuedTimestamp":1176999451.89716,"ffcState":"FFC_DESIRED"}
#000381 78/10 fps:{"shutterState":"ON","shutterTemperature":309.940002441406,"usbNotifiedTimestamp":1176999452.01968,"usbEnqueuedTimestamp":1176999452.0214,"ffcState":"FFC_PROGRESS"}
#000382 75/10 fps:{"shutterState":"FFC","shutterTemperature":309.940002441406,"usbNotifiedTimestamp":1176999452.35303,"usbEnqueuedTimestamp":1176999452.35494,"ffcState":"FFC_VALID_RAD"}
#000383 75/10 fps:{"shutterState":"FFC","shutterTemperature":309.940002441406,"usbNotifiedTimestamp":1176999452.46615,"usbEnqueuedTimestamp":1176999452.46842,"ffcState":"FFC_VALID_RAD"}
#000384 75/10 fps:{"shutterState":"FFC","shutterTemperature":309.940002441406,"usbNotifiedTimestamp":1176999452.57972,"usbEnqueuedTimestamp":1176999452.58159,"ffcState":"FFC_VALID_RAD"}
#000385 75/10 fps:{"shutterState":"FFC","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999452.69317,"usbEnqueuedTimestamp":1176999452.6951,"ffcState":"FFC_VALID_RAD"}
#000386 72/10 fps:{"shutterState":"FFC","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999453.16082,"usbEnqueuedTimestamp":1176999453.16271,"ffcState":"FFC_VALID_RAD"}
#000387 70/10 fps:{"shutterState":"FFC","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999453.37775,"usbEnqueuedTimestamp":1176999453.38077,"ffcState":"FFC_VALID_RAD"}
#000388 71/10 fps:{"shutterState":"ON","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999453.49103,"usbEnqueuedTimestamp":1176999453.4927,"ffcState":"FFC_VALID_RAD"}
#000389 71/10 fps:{"shutterState":"ON","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999453.60539,"usbEnqueuedTimestamp":1176999453.60742,"ffcState":"FFC_VALID_RAD"}
#000390 71/10 fps:{"shutterState":"ON","shutterTemperature":309.950012207031,"usbNotifiedTimestamp":1176999453.71995,"usbEnqueuedTimestamp":1176999453.72604,"ffcState":"FFC_VALID_RAD"}



Anybody have any ideas on how to manually trigger FFC by writing to USB endpoints?

You can simple debug all USB commands with the Flir SDK by using the extracted flir java.class.
Set a breakpoint in FLIROneSDKBundle/FLIRONEExampleApplication/app/src/main/java/com/flir/flironesdk/usb/UsbCommunicator.java
in function    public void sendDataToDevice(byte[] data, ProtocolType protocolType)
on             sendData(destinationEndpoint, data, data.length);
and watch for array "data"


Here you can download a working SDK sample with the extracted java.class (see my post above)
 see path FLIROneSDKBundle\FLIRONEExampleApplication\app\src\main\java\com\flir\flironesdk\usb

have fun
http://www.file-upload.net/download-11040066/FLIROneSDKBundle04-Basis.zip.html

as sample the tune command
{"type":"setOption","data":{"option":"doFFC","value":true}}
Code: [Select]
data = {byte[60]@21045}
0 = 123 (0x7B)
1 = 34 (0x22)
2 = 116 (0x74)
3 = 121 (0x79)
4 = 112 (0x70)
5 = 101 (0x65)
6 = 34 (0x22)
7 = 58 (0x3A)
8 = 34 (0x22)
9 = 115 (0x73)
10 = 101 (0x65)
11 = 116 (0x74)
12 = 79 (0x4F)
13 = 112 (0x70)
14 = 116 (0x74)
15 = 105 (0x69)
16 = 111 (0x6F)
17 = 110 (0x6E)
18 = 34 (0x22)
19 = 44 (0x2C)
20 = 34 (0x22)
21 = 100 (0x64)
22 = 97 (0x61)
23 = 116 (0x74)
24 = 97 (0x61)
25 = 34 (0x22)
26 = 58 (0x3A)
27 = 123 (0x7B)
28 = 34 (0x22)
29 = 111 (0x6F)
30 = 112 (0x70)
31 = 116 (0x74)
32 = 105 (0x69)
33 = 111 (0x6F)
34 = 110 (0x6E)
35 = 34 (0x22)
36 = 58 (0x3A)
37 = 34 (0x22)
38 = 100 (0x64)
39 = 111 (0x6F)
40 = 70 (0x46)
41 = 70 (0x46)
42 = 67 (0x43)
43 = 34 (0x22)
44 = 44 (0x2C)
45 = 34 (0x22)
46 = 118 (0x76)
47 = 97 (0x61)
48 = 108 (0x6C)
49 = 117 (0x75)
50 = 101 (0x65)
51 = 34 (0x22)
52 = 58 (0x3A)
53 = 116 (0x74)
54 = 114 (0x72)
55 = 117 (0x75)
56 = 101 (0x65)
57 = 125 (0x7D)
58 = 125 (0x7D)
59 = 0 (0x0)
protocolType = {UsbCommunicator$ProtocolType@20949} "CONFIGURATION"

PS: Please don't forget to post your knowledge here!

Offline eren

  • Newbie
  • Posts: 4
  • Country: tr
Re: Question about FLIR One for Android
« Reply #174 on: March 18, 2016, 05:31:24 pm »
Hi Tomas,

thanks a bunch for your suggestion -- it worked!  :-+  after dumping the data argument of sendDataToDevice and tinkering with the app, I got the following code to trigger FFC frames:

Code: [Select]
unsigned char my_string2[16]={0xcc,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0xb9,0xcb,0xa2,0x99};

                r = libusb_bulk_transfer(devh, 2, my_string2, length, &transferred, 0);
                if(r == 0 && transferred == length)
                    printf("\nWrite successful!");
                else
                    printf("\nError in write! res = %d and transferred = %d\n", r, transferred);

                char my_string[128];
                transferred = 0;

                strcpy(my_string, "{\"type\":\"setOption\",\"data\":{\"option\":\"doFFC\",\"value\":true}}");
                length = strlen(my_string)+1;

                unsigned char *my_string1 = (unsigned char*)my_string;

                transferred = 0;

                r = libusb_bulk_transfer(devh, 2, my_string1, length, &transferred, 0);
                if(r == 0 && transferred == length)
                {
                    printf("\nWrite successful!");
                    printf("\nSent %d bytes with string: %s\n", transferred, my_string);
                }
                else
                    printf("\nError in write! res = %d and transferred = %d\n", r, transferred);
* note that I'm sending two messages -- the clear string doesn't work without the binary "pre-message"  ???


unfortunately, this didn't clear up the "rainbow frames", which sort of look like the attached image.

Even after I remove FFC frames, I also see the "wavy" pixel intensity behavior you see (also attached graph). You can also see the "rainbow frames" where the frame max/mean go up  by a few hundred intensity values and stay up for a few hundred frames.

This behavior persists even if I uplug and restart the camera. I'm guessing it has to do with overheating -- I'm using the camera on continual charge, and while I don't always get the flashing red light I do sooner or later always end up with rainbow frames. Seeing as how reboots don't help I'm guessing it might be a hardware issue, so it'll probably be with us until FLIR find a firmware workaround.

Thanks a bunch! Didn't solve the immediate issue, but learned a lot  ;D
Eren

« Last Edit: March 18, 2016, 05:33:53 pm by eren »
 

Offline Clay

  • Newbie
  • Posts: 1
  • Country: us
Re: Question about FLIR One for Android
« Reply #175 on: March 18, 2016, 07:15:20 pm »
I'm guessing it has to do with overheating -- I'm using the camera on continual charge, and while I don't always get the flashing red light I do sooner or later always end up with rainbow frames.

It may be caused by the battery heating up.

Attached is an image I took after triggering the shutter a bunch of times in a short time span.
You can see a thermal gradient across the image.  I am guessing that the motor for the shutter is near the corner of the sensor and that it is heating up.
 

Offline Macbeth

  • Super Contributor
  • ***
  • Posts: 2559
  • Country: gb
Re: Question about FLIR One for Android
« Reply #176 on: March 18, 2016, 09:22:25 pm »
Bookmarking because I've finally given up waiting for F1G2 to be in stock and backordered. Hopefully I get one the first week of April  :-+
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #177 on: March 19, 2016, 12:33:44 am »
I can't confirm the temperature gradient (rainbow).
My F1G2 runs several days by continuous battery charging at 20°C room temperature without problems, but I noticed a really battery heating like a fast charging smartphone.



I'm worried about the duration of the shutter mechanism (640 movements daily)

Offline eren

  • Newbie
  • Posts: 4
  • Country: tr
Re: Question about FLIR One for Android
« Reply #178 on: March 21, 2016, 10:50:28 am »
Interesting -- what's your shutter temperature after a full days run? Is your LED indicator blinking red at any point? I will get the red blinking every time after I run it for 3-5 hours, and start seeing something like Clay's sample frame fairly regularly. I also see that the FFC process starts taking longer -- I'm guessing that when I see the rainbow frames, the FFC has failed.

The shutter motor heating up sounds like a likely scenario, but I'd also suspect the battery overheating during charging. If only there were a way to disengage the battery entirely when plugged into DC power...  ???
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de
Re: Question about FLIR One for Android
« Reply #179 on: March 21, 2016, 09:55:53 pm »
Interesting -- what's your shutter temperature after a full days run? Is your LED indicator blinking red at any point?

yes, the LED is blinking red :(

I can't give a better answer for shutter temperature as described here
https://www.eevblog.com/forum/thermal-imaging/flir-one-thermal-imaging-camera-teardown-and-hacks/msg848878/#msg848878

Offline sadae

  • Contributor
  • Posts: 8
  • Country: es
Re: Question about FLIR One for Android
« Reply #180 on: April 04, 2016, 09:25:49 pm »
Hello, I have a problem saving different types of files, I did this code:

Code: [Select]
                    try {

                            lastSavedPath = path + "/" + "Thermal+" + fileName;
                            renderedImage.getFrame().save(new File(lastSavedPath), RenderedImage.Palette.Iron, RenderedImage.ImageType.ThermalRGBA8888Image);


                            MediaScannerConnection.scanFile(context,
                                    new String[]{path + "/" + "Thermal+" + fileName}, null,
                                    new MediaScannerConnection.OnScanCompletedListener() {
                                        @Override
                                        public void onScanCompleted(String path, Uri uri) {
                                            Log.i("ExternalStorage", "Scanned " + path + ":");
                                            Log.i("ExternalStorage", "-> uri=" + uri);


                                        }

                                    });

                    }catch (Exception e){
                        e.printStackTrace();
                    }

                    try{

                            lastSavedPath = path + "/" + "RGB+" + fileName;
                            renderedImage.getFrame().save(new File(lastSavedPath), RenderedImage.Palette.Iron, RenderedImage.ImageType.VisualYCbCr888Image);

                            MediaScannerConnection.scanFile(context,
                                    new String[]{path + "/" + "RGB+" + fileName}, null,
                                    new MediaScannerConnection.OnScanCompletedListener() {
                                        @Override
                                        public void onScanCompleted(String path, Uri uri) {
                                            Log.i("ExternalStorage", "Scanned " + path + ":");
                                            Log.i("ExternalStorage", "-> uri=" + uri);

                                        }

                                    });

                    }catch (Exception e){
                        e.printStackTrace();
                    }


But I don't know why one time save the RGB photo, another time save the thermal photo and another time save the both files  :wtf:
« Last Edit: April 04, 2016, 10:09:08 pm by sadae »
 

Offline tomas123

  • Frequent Contributor
  • **
  • Posts: 832
  • Country: de