start-jsk / 2015-semi

2 stars 6 forks source link

kinectのdepth情報を使いたい #31

Open kimhc6028 opened 8 years ago

kimhc6028 commented 8 years ago

kinectから画素ごとのdepth情報を直接いじって画像処理してみたいです。 jsk_recognitionのどれかdepth情報を使っているプログラムを探して参照にしようと思っています。

k-okada commented 8 years ago

https://github.com/jsk-ros-pkg/jsk_recognition/blob/93584cec5e6a093a068a63978e66dbb851425000/jsk_pcl_ros/src/depth_image_creator_nodelet.cpp とかかな、いろいろな機能ははいっているから読むのはむづかしいかも https://github.com/ros-perception/vision_opencv/tree/indigo/opencv_apps/src/nodelet みてimageをdepthimage にするのもある

やりたいことはなんだろう。ある点の距離とかがしりたいのかな?

◉ Kei Okada

2015/12/01 0:30、Kim Heecheol notifications@github.com のメッセージ:

kinectから画素ごとのdepth情報を直接いじって画像処理してみたいです。 jsk_recognitionのどれかdepth情報を使っているプログラムを探して参照にしようと思っています。

— Reply to this email directly or view it on GitHub.

kimhc6028 commented 8 years ago

https://en.wikipedia.org/wiki/Braitenberg_vehicle braitenberg's vehicleをkinectを使って実装してみたいです。kinect画像の列ごとに距離情報を集めて、重みをかけて車輪をコントロールすることで衝突回避が実装できるかも知れないと思っています。 つまり、映っている画像全体の距離情報が知りたいです。

k-okada commented 8 years ago

なるほど.であれば,depthimage (pointcloudではなく)をsubscribeして,画像処理する,というプログラムを書いたらいいと思います. https://www.google.co.jp/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&client=ubuntu#q=depthimageptr+ros とか, https://github.com/wg-perception/people/blob/indigo-devel/face_detector/src/face_detection.cpp みたらいいとおもいます

◉ Kei Okada

2015-12-01 1:09 GMT+09:00 Kim Heecheol notifications@github.com:

https://en.wikipedia.org/wiki/Braitenberg_vehicle braitenberg's vehicleをkinectを使って実装してみたいです。kinect画像の列ごとに距離情報を集めて、重みをかけて車輪をコントロールすることで衝突回避が実装できるかも知れないと思っています。 つまり、映っている画像全体の距離情報が知りたいです。

— Reply to this email directly or view it on GitHub https://github.com/start-jsk/2015-semi/issues/31#issuecomment-160673385.

kimhc6028 commented 8 years ago

http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython depth情報を取ることはできたと思います。 capture_depth でも、/camera/depth_registered/imageをsubscribeしていますが、これはもともと画面が左右に分割されていますか?

  def __init__(self):
    #self.image_pub = rospy.Publisher("image_topic_2",Image)                                                                                                             

    cv2.namedWindow("Depth Image", 1)
    self.bridge = CvBridge()
    self.image_sub = rospy.Subscriber("camera/depth_registered/image",Image,self.callback)

  def callback(self,data):
    try:
      depth_image = self.bridge.imgmsg_to_cv2(data, '32FC1')

      depth_array = np.array(depth_image, dtype=np.float32)
      cv2.normalize(depth_array, depth_array, 0, 1, cv2.NORM_MINMAX)
      cv2.imwrite('capture_depth.png',depth_array*255)
    except CvBridgeError as e:
      print(e)

    cv2.waitKey(3)
k-okada commented 8 years ago

.おしい.たぶんcharとshortが違っていると思います.

◉ Kei Okada

On Tue, Dec 1, 2015 at 7:54 PM, Kim Heecheol notifications@github.com wrote:

http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython depth情報を取ることはできたと思います。 [image: capture_depth] https://cloud.githubusercontent.com/assets/15006217/11498756/ccdc5e00-9864-11e5-9484-7db2b8304a34.png

— Reply to this email directly or view it on GitHub https://github.com/start-jsk/2015-semi/issues/31#issuecomment-160933999.

taka084 commented 7 years ago

同じ状況で悩みましたが、下記の方法で解決しました。

depth_image = self.bridge.imgmsg_to_cv2(data, '32FC1')

depth_image = self.bridge.imgmsg_to_cv2(data, "passthrough")

こうすることで、depth_imageをfloat32で得られます。よって

depth_array = np.array(depth_image, dtype=np.float32)

これも不要となります。

http://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython