Ask Your Question

Revision history [back]

Error while publishing camera images.

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.but when i run the code, its giving error.

image description

i can see my camera indication light is on.Even the camera1 gui is not coming. How can i see my published camera images? My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

    cv2.imshow("camera1",frame)

    msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")

        if ret:
            rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.

Error while publishing camera images.

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.but when i run the code, its giving error.

image description

melvin@melvin-HP-Notebook:~$ python 1.py 
[INFO] [1523284870.514282]: Capturing image failed.
[INFO] [1523284870.531012]: Capturing image failed.
[INFO] [1523284870.541091]: Capturing image failed.
[INFO] [1523284870.554476]: Capturing image failed.
[INFO] [1523284870.607010]: Capturing image failed.
[INFO] [1523284870.676506]: Capturing image failed.
[INFO] [1523284870.743455]: Capturing image failed.
[INFO] [1523284870.812599]: Capturing image failed.
[INFO] [1523284870.877678]: Capturing image failed.
[INFO] [1523284870.944492]: Capturing image failed.
[INFO] [1523284871.012462]: Capturing image failed.
[INFO] [1523284871.081950]: Capturing image failed.
[INFO] [1523284871.148926]: Capturing image failed.
[INFO] [1523284871.216495]: Capturing image failed.
[INFO] [1523284871.284706]: Capturing image failed.
[INFO] [1523284871.348706]: Capturing image failed.
[INFO] [1523284871.416538]: Capturing image failed.
[INFO] [1523284871.484537]: Capturing image failed.
[INFO] [1523284871.552556]: Capturing image failed.
[INFO] [1523284871.620480]: Capturing image failed.
[INFO] [1523284871.688887]: Capturing image failed.

i can see my camera indication light is on.Even the camera1 gui is not coming. How can i see my published camera images? My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

    cv2.imshow("camera1",frame)

    msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")

        if ret:
            rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.

Error while publishing camera images.

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.but when i run the code, its giving error.

melvin@melvin-HP-Notebook:~$ python 1.py 
[INFO] [1523284870.514282]: Capturing image failed.
[INFO] [1523284870.531012]: Capturing image failed.
[INFO] [1523284870.541091]: Capturing image failed.
[INFO] [1523284870.554476]: Capturing image failed.
[INFO] [1523284870.607010]: Capturing image failed.
[INFO] [1523284870.676506]: Capturing image failed.
[INFO] [1523284870.743455]: Capturing image failed.
[INFO] [1523284870.812599]: Capturing image failed.
[INFO] [1523284870.877678]: Capturing image failed.
[INFO] [1523284870.944492]: Capturing image failed.
[INFO] [1523284871.012462]: Capturing image failed.
[INFO] [1523284871.081950]: Capturing image failed.
[INFO] [1523284871.148926]: Capturing image failed.
[INFO] [1523284871.216495]: Capturing image failed.
[INFO] [1523284871.284706]: Capturing image failed.
[INFO] [1523284871.348706]: Capturing image failed.
[INFO] [1523284871.416538]: Capturing image failed.
[INFO] [1523284871.484537]: Capturing image failed.
[INFO] [1523284871.552556]: Capturing image failed.
[INFO] [1523284871.620480]: Capturing image failed.
[INFO] [1523284871.688887]: Capturing image failed.

i can see my camera indication light is on.Even the camera1 gui is not coming. How can i see my published camera images? My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

     cv2.imshow("camera1",frame)

     msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")

        if ret:
            rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.

Error while publishing camera images.

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.but when i run the code, its giving error.

melvin@melvin-HP-Notebook:~$ python 1.py 
[INFO] [1523284870.514282]: Capturing image failed.
[INFO] [1523284870.531012]: Capturing image failed.
[INFO] [1523284870.541091]: Capturing image failed.
[INFO] [1523284870.554476]: Capturing image failed.
[INFO] [1523284870.607010]: Capturing image failed.
[INFO] [1523284870.676506]: Capturing image failed.
[INFO] [1523284870.743455]: Capturing image failed.
[INFO] [1523284870.812599]: Capturing image failed.
[INFO] [1523284870.877678]: Capturing image failed.
[INFO] [1523284870.944492]: Capturing image failed.
[INFO] [1523284871.012462]: Capturing image failed.
[INFO] [1523284871.081950]: Capturing image failed.
[INFO] [1523284871.148926]: Capturing image failed.
[INFO] [1523284871.216495]: Capturing image failed.
[INFO] [1523284871.284706]: Capturing image failed.
[INFO] [1523284871.348706]: Capturing image failed.
[INFO] [1523284871.416538]: Capturing image failed.
[INFO] [1523284871.484537]: Capturing image failed.
[INFO] [1523284871.552556]: Capturing image failed.
[INFO] [1523284871.620480]: Capturing image failed.
[INFO] [1523284871.688887]: Capturing image failed.

i can see my camera indication light is on.Even the camera1 gui is not coming. How can i see my published camera images? My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

        cv2.imshow("camera1",frame)

        msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")

        if ret:
            rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.

Error while publishing How to add multiple publishers to get 4 camera images. images?

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.but when i run the code, its giving error.

melvin@melvin-HP-Notebook:~$ python 1.py 
[INFO] [1523284870.514282]: Capturing image failed.
[INFO] [1523284870.531012]: Capturing image failed.
[INFO] [1523284870.541091]: Capturing image failed.
[INFO] [1523284870.554476]: Capturing image failed.
[INFO] [1523284870.607010]: Capturing image failed.
[INFO] [1523284870.676506]: Capturing image failed.
[INFO] [1523284870.743455]: Capturing image failed.
[INFO] [1523284870.812599]: Capturing image failed.
[INFO] [1523284870.877678]: Capturing image failed.
[INFO] [1523284870.944492]: Capturing image failed.
[INFO] [1523284871.012462]: Capturing image failed.
[INFO] [1523284871.081950]: Capturing image failed.
[INFO] [1523284871.148926]: Capturing image failed.
[INFO] [1523284871.216495]: Capturing image failed.
[INFO] [1523284871.284706]: Capturing image failed.
[INFO] [1523284871.348706]: Capturing image failed.
[INFO] [1523284871.416538]: Capturing image failed.
[INFO] [1523284871.484537]: Capturing image failed.
[INFO] [1523284871.552556]: Capturing image failed.
[INFO] [1523284871.620480]: Capturing image failed.
[INFO] [1523284871.688887]: Capturing image failed.

i can see my camera indication light is on.Even the camera1 gui is not coming. How can i see my published camera images? camera.it works..but how to add multiple publishers for camera. My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

        cv2.imshow("camera1",frame)
         cv2.waitKey(1)
        msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")

        if ret:
            rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.

How to add multiple publishers to get 4 camera images?

Hai, I am writing a rospy code to publish images from 4 cameras. Currently, i trying it with my laptop camera.it works..but how to add multiple publishers for camera. My code is...

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Image
import cv2
import numpy as np
from cv_bridge import CvBridge, CvBridgeError

def webcam_pub():
    pub = rospy.Publisher('webcam/image_raw', Image, queue_size=1)
    rospy.init_node('webcam_pub', anonymous=True)
    rate = rospy.Rate(60) # 60hz

    cam = cv2.VideoCapture(0)
    bridge = CvBridge()

    if not cam.isOpened():
         sys.stdout.write("Webcam is not available")
         return -1

    while not rospy.is_shutdown():
        ret, frame = cam.read()

        cv2.imshow("camera1",frame)
        cv2.waitKey(1)
        msg = bridge.cv2_to_imgmsg(frame, encoding="bgr8")
         if ret:
             rospy.loginfo("Capturing image failed.")

        pub.publish(msg)
        rate.sleep()


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

I am using UBUNTU 16.04, KINETIC distro.