optris PI450 ros版在ubuntu下的安装

参考官网
https://wiki.ros.org/optris_drivers
安装教程http://documentation.evocortex.com/libirimager2/html/Installation.html
一步一步做下来,make还是cmake的时候疯狂报错
而且看起来不是缺包是代码的错(redefinition)
在这里插入图片描述
搜了一下google和github好像也没有什么人遇到过。
不想改了,改用/example/python下面的python版吧。
再写个ros topic的listener和talker就行了。
后面补充……

注意:镜头是可以拧的来调焦,我以为是程序哪里需要设分辨率还改了好久。。。。
在这里插入图片描述
分享迷惑

补充
换了个电脑重新安装了一次,几个新问题
1、sudo usermod -a -G video <username>这个命令以后要重启才能生效,groups后能看到新添加的vedio
2、sudo ir_download_calibration这一步可能卡住很久,大概是因为网络的问题,可以直接拷贝到指定目录下
3、c++版的irviewer是/example/oop文件夹下的,make时可能会报错

/usr/include/libirimager/IRArray.h:63:37: error: expected ‘,’ or ‘...’ before ‘&&’ token
     IRArray<T>& operator=(IRArray<T>&& obj);
                                     ^
/usr/include/libirimager/IRArray.h: In copy constructor ‘evo::IRArray<T>::IRArray(const evo::IRArray<T>&):
/usr/include/libirimager/IRArray.h:122:84: warning: delegating constructors only available with -std=c++11 or -std=gnu++11
 IRArray<T>::IRArray(const evo::IRArray<T> &obj) : IRArray(obj._size, obj._data)
                                                                               ^
/usr/include/libirimager/IRArray.h: At global scope:
/usr/include/libirimager/IRArray.h:149:60: error: expected ‘,’ or ‘...’ before ‘&&’ token
 evo::IRArray<T>& evo::IRArray<T>::operator=(evo::IRArray<T>&& obj)
                                                            ^
/usr/include/libirimager/IRArray.h: In member function ‘evo::IRArray<T>& evo::IRArray<T>::operator=(evo::IRArray<T>):
/usr/include/libirimager/IRArray.h:151:13: error: ‘obj’ was not declared in this scope
     _size = obj._size;
             ^
In file included from /home/robot/optris_ir/examples/minimal/serializeRaw.cpp:15:0:
/usr/include/libirimager/IRImager.h: At global scope:
/usr/include/libirimager/IRImager.h:586:3: warning: scoped enums only available with -std=c++11 or -std=gnu++11
   enum class RadialDistortionCorrectionMode
   ^
CMakeFiles/serialize_raw.dir/build.make:62: recipe for target 'CMakeFiles/serialize_raw.dir/serializeRaw.cpp.o' failed
make[2]: *** [CMakeFiles/serialize_raw.dir/serializeRaw.cpp.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/serialize_raw.dir/all' failed
make[1]: *** [CMakeFiles/serialize_raw.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决办法,改CMakeList,这一行加上-std=c++11

SET(CMAKE_CXX_FLAGS "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0")

之前遇到的那个redefinition的问题,换了个电脑就好了。。。。

4、python版的节点也写好了
pub_ir_image.py
可以供参考,其实就是把之前的代码复制过来再加一个topic发布

#!/usr/bin/env python
#coding:utf-8

import rospy
import sys
sys.path.append('.')
import cv2
import os
import numpy as np
from test_py.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import direct_binding_usb_show 

from ctypes.util import find_library
import numpy as np
import ctypes as ct

#Define EvoIRFrameMetadata structure for additional frame infos
class EvoIRFrameMetadata(ct.Structure):
     _fields_ = [("counter", ct.c_uint),
                 ("counterHW", ct.c_uint),
                 ("timestamp", ct.c_longlong),
                 ("timestampMedia", ct.c_longlong),
                 ("flagState", ct.c_int),
                 ("tempChip", ct.c_float),
                 ("tempFlag", ct.c_float),
                 ("tempBox", ct.c_float),
                 ]

def pubImage():
    rospy.init_node('pubImage',anonymous = True)
    pub = rospy.Publisher('ShowImage', Image, queue_size = 10)
    rate = rospy.Rate(10)
    bridge = CvBridge()
    gt_imdb = []


    if os.name == 'nt':
            #windows:
            libir = ct.CDLL("c:\\irDirectSDK\\sdk\\x64\\libirimager.dll") 
    else:
            #linux:
            libir = ct.cdll.LoadLibrary(ct.util.find_library("irdirectsdk"))

    #path to config xml file
    pathXml = ct.c_char_p(b'/home/robot/optris_ir/examples/config/20062422.xml')

    # init vars
    pathFormat = ct.c_char_p()
    pathLog = ct.c_char_p(b'logfilename')

    palette_width = ct.c_int()
    palette_height = ct.c_int()

    thermal_width = ct.c_int()
    thermal_height = ct.c_int()

    serial = ct.c_ulong()

    # init EvoIRFrameMetadata structure
    metadata = EvoIRFrameMetadata()

    # init lib
    ret = libir.evo_irimager_usb_init(pathXml, pathFormat, pathLog)
    if ret != 0:
            print "error at init"
            exit(ret)


    # get the serial number
    ret = libir.evo_irimager_get_serial(ct.byref(serial))
    print 'serial: ' + str(serial.value)

    # get thermal image size
    libir.evo_irimager_get_thermal_image_size(ct.byref(thermal_width), ct.byref(thermal_height))
    print 'thermal width: ' + str(thermal_width.value)
    print 'thermal height: ' + str(thermal_height.value)

    # init thermal data container
    np_thermal = np.zeros([thermal_width.value * thermal_height.value], dtype=np.uint16)
    npThermalPointer = np_thermal.ctypes.data_as(ct.POINTER(ct.c_ushort))

    # get palette image size, width is different to thermal image width duo to stride alignment!!!
    libir.evo_irimager_get_palette_image_size(ct.byref(palette_width), ct.byref(palette_height))
    print 'palette width: ' + str(palette_width.value)
    print 'palette height: ' + str(palette_height.value)

    # init image container
    np_img = np.zeros([palette_width.value * palette_height.value * 3], dtype=np.uint8)
    npImagePointer = np_img.ctypes.data_as(ct.POINTER(ct.c_ubyte))

    # for item in os.listdir(path):
    #     gt_imdb.append(os.path.join(path,item))
    while not rospy.is_shutdown():
        # image = cv2.imread(path)
        #get thermal and palette image with metadat
        ret = libir.evo_irimager_get_thermal_palette_image_metadata(thermal_width, thermal_height, npThermalPointer, palette_width, palette_height, npImagePointer, ct.byref(metadata))

        if ret != 0:
            print 'error on evo_irimager_get_thermal_palette_image ' + str(ret)
            continue

        #calculate total mean value
        mean_temp = np_thermal.mean()
        mean_temp = mean_temp / 10. - 100

        print 'mean temp: ' + str(mean_temp)

        #display palette image
        image_ir = np_img.reshape(palette_height.value, palette_width.value, 3)[:,:,::-1]
        # image = cv2.resize(image,(900,450))
        pub.publish(bridge.cv2_to_imgmsg(image_ir,"bgr8"))
        cv2.imshow("lala",image_ir)
        #cv2.waitKey(0)
        rate.sleep()

if __name__ == '__main__':
    try:
        pubImage()
    except rospy.ROSInterruptException:
        pass

然后自己加上CMakelist和package.xml再catkin_make
直接

rosrun test_py pub_ir_image.py

就可以了!

结果展示
在这里插入图片描述
在这里插入图片描述

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值