ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

abroun's profile - activity

2014-09-26 10:09:04 -0500 received badge  Good Answer (source)
2012-08-21 02:16:56 -0500 received badge  Famous Question (source)
2012-08-21 02:16:56 -0500 received badge  Popular Question (source)
2012-08-21 02:16:56 -0500 received badge  Notable Question (source)
2011-10-25 00:32:22 -0500 received badge  Nice Answer (source)
2011-07-18 07:13:36 -0500 received badge  Enlightened (source)
2011-07-18 07:13:35 -0500 received badge  Good Answer (source)
2011-07-18 06:54:51 -0500 received badge  Nice Answer (source)
2011-07-18 06:03:45 -0500 received badge  Teacher (source)
2011-07-18 06:01:10 -0500 answered a question opencv pixel locations

If you haven't already, I'd suggest looking at NumPy for manipulating your OpenCV images in Python. If you load your images as CvMat objects instead of IplImages then you can manipulate them as NumPy objects without copying the data.

NumPy takes a while to get your head around, but once you do you can use techniques such as the ones given here to achieve what you want.

Based on that, running this program

#! /usr/bin/env python

import cv
import numpy

cvImg = cv.LoadImageM( "testImage.png",     # Must use LoadImageM
    iscolor=cv.CV_LOAD_IMAGE_GRAYSCALE )
npImg = numpy.asarray( cvImg )  # No copying takes place

coordList = numpy.argwhere( npImg == 255 )
numWhitePoints = len( coordList )

print coordList
print "Found {0} points".format( numWhitePoints )

on your image should output like this

[[ 97 318]
 [ 97 322]
 [ 97 323]
   .. ..
   .. ..
 [141 200]
 [146 189]
 [153 178]]
Found 216 points
2011-07-18 05:35:11 -0500 commented answer Is there an Inverse Kinematics Teleop system available anywhere?
That sounds great. I'm currently hacking together a small teleop program for myself that uses the interactive markers and stuff from the PCV. Your Planning tool sounds much more comprehensive though, so whenever you have something ready for public consumption I'd love to have a look. :) Cheers Alan
2011-07-18 05:16:19 -0500 received badge  Supporter (source)
2011-07-18 05:16:09 -0500 marked best answer Is there an Inverse Kinematics Teleop system available anywhere?

Hi,

We are currently developing a more comprehensive tool for interacting with Planning Scenes (the stuff that your robot is trying to not run into) - this tool allows you to create planning scenes, save to and load from a database, create different motion plan requests, generate, save, and visualize trajectories, and send those trajectories to controllers and record the results. It should be a really neat and powerful tool. We have a working prototype for the PR2 - we haven't yet made this robot agnostic, but that's a near term goal.

This tool will be released with Electric, but not in the arm_navigation stack - we're not ready to label this a 1.0 tool yet. Once we've got a release out we'll be adding a tutorial.

And if you have any feedback on tools like the Planning Components Visualizer or the tutorials, we'd love to hear them!

2011-07-18 05:16:09 -0500 received badge  Scholar (source)
2011-07-17 23:42:03 -0500 answered a question How to save sensor_msgs/image as .jpeg or .bmp files. Is OpenCV indispensable?

The advantage of using OpenCV is that you'll be able save you image in a variety of formats using just one or two lines.

If you want to avoid using OpenCV then you either have to roll your own code for saving an image in your chosen format, or use one of the standard libraries such as libJPEG. The choice you make depends upon the amount of time you have to write, test and debug your own code versus any aversion you may have to linking in another library.

A quick and dirty solution that I sometimes use when I just want to dump an image out is to use one of the Netpbm ASCII formats. This will result in huge files, but it's not meant to be an elegant solution. ;)

Something like this should work for you. Use a filename with a .ppm extension and Ubuntu or the GIMP will be able to open it.

void SaveImageAsPPM( const sensor_msgs::ImageConstPtr& msg, const char* filename )
{
  if ( msg->encoding != "rgb8" )
  {
    return;  // Can only handle the rgb8 encoding
  }

  FILE* file = fopen( filename, "w" );

  fprintf( file, "P3\n" );
  fprintf( file, "%i %i\n", msg->width, msg->height );
  fprintf( file, "255\n" );

  for ( uint32_t y = 0; y < msg->height; y++ )
  {
    for ( uint32_t x = 0; x < msg->width; x++ )
    {
      // Get indices for the pixel components
      uint32_t redByteIdx = y*msg->step + 3*x;
      uint32_t greenByteIdx = redByteIdx + 1;
      uint32_t blueByteIdx = redByteIdx + 2;

      fprintf( file, "%i %i %i ", 
        msg->data[ redByteIdx ], 
        msg->data[ greenByteIdx ], 
        msg->data[ blueByteIdx ] );
    }
    fprintf( file, "\n" );
  }

  fclose( file );
}
2011-07-17 22:32:37 -0500 asked a question Is there an Inverse Kinematics Teleop system available anywhere?

I've been playing around with the Planning Components Visualiser from the upcoming E-Turtle distribution and I must say, it's very cool. :)

As far as I can see though, it only allows you to preview the results of an IK plan or of posing the joints in a kinematic chain. Ideally what I'd like is to be able to pose my robot in RVIZ using the interactive markers and then press another button that moves my robot to the new pose.

Has anyone written such a system or does someone with connections to Willow Garage know if such a program is planned for inclusion in the forthcoming E-Turtle release?