from cv_bridge.boost.cv_bridge_boost import getCvType ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/boost/cv_bridge_boost.so: wrong ELF class: ELFCLASS64

asked 2021-01-27 10:25:31 -0500

sudhan gravatar image

Traceback (most recent call last): File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "tes.py", line 39, in callback self.cv_imge = self.bridge.imgmsg_to_cv2(data, "bgr8") File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 163, in imgmsg_to_cv2 dtype, n_channels = self.encoding_to_dtype_with_channels(img_msg.encoding) File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 99, in encoding_to_dtype_with_channels return self.cvtype2_to_dtype_with_channels(self.encoding_to_cvtype2(encoding)) File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 91, in encoding_to_cvtype2 from cv_bridge.boost.cv_bridge_boost import getCvType ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/boost/cv_bridge_boost.so: wrong ELF class: ELFCLASS64

!/usr/bin/env python

from __future__ import print_function from __future__ import division

import sys import rospy import cv2 from std_msgs.msg import * import sensor_msgs.msg from cv_bridge import CvBridge, CvBridgeError import numpy as np ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'

if ros_path in sys.path:

sys.path.remove(ros_path)

import pytesseract import shutil import os import random try: from PIL import Image except ImportError: import Image

sys.path.append('/opt/ros/kinetic/lib/python2.7/dist-packages')

class teser: def __init__(self): self.subVideo = rospy.Subscriber('/image',sensor_msgs.msg.Image,self.callback) self.subVideo2 = rospy.Subscriber('/image1',sensor_msgs.msg.Image,self.callback1) self.subVideo3 = rospy.Subscriber('/image2',sensor_msgs.msg.Image,self.callback2) self.bridge = CvBridge() def callback(self,data): try: self.cv_imge = self.bridge.imgmsg_to_cv2(data, "bgr8") frame = self.cv_image extractedInformation = pytesseract.image_to_string(Image.open(frame)) print(extractedInformation) ger = extractedInformation.split() print(ger) except CvBridgeError as e: print(e) def callback1(self,data): try: self.cv_image1 = self.bridge.imgmsg_to_cv2(data, "bgr8") frame1 = self.cv_image1 extractedInformation = pytesseract.image_to_string(Image.open(frame1)) print(extractedInformation) ger = extractedInformation.split() print(ger) except CvBridgeError as e: print(e) def callback2(self,data): try: self.cv_image2 = self.bridge.imgmsg_to_cv2(data, "bgr8") frame2 = self.cv_image2 extractedInformation = pytesseract.image_to_string(Image.open(frame2)) print(extractedInformation) ger = extractedInformation.split() print(ger) except CvBridgeError as e: print(e)

def main(self):

  # cap=cv2.VideoCapture('project_video.mp4')
  ticks = 0
  print("yes")

if __name__ == "__main__": ic = teser() rospy.init_node('tesser_node', anonymous=True) ic.main()

try:
  rospy.spin()
except KeyboardInterrupt:
  print("Shutting down")

python 3.7- need to use both ros and opencv and pytesseract

edit retag flag offensive close merge delete

Comments

there are many questions about mixing python3 with ROS kinetic/melodic that is built against python2. See e.g. #q237613, #q262551 and #q285412. Just have a look at the number of search results.

If you need to use python 3, you should use ROS noetic. Everything else will require you to build everything from source.

If you feel this is enough of an answer, please close this question as resolved or duplicate. Thank you.

mgruhler gravatar image mgruhler  ( 2021-01-29 01:24:32 -0500 )edit