sbonner1 / Senior-Design-I

Senior year team project for Senior Design I. The goal is to build and program a robotic arm to recognize a simple image and attempt to replicate it.
0 stars 3 forks source link

Josh Coady's Journal #2

Closed jcoady9 closed 9 years ago

jcoady9 commented 10 years ago

initial comment.

jcoady9 commented 10 years ago

I had a meeting with Dr. Martin to answer some of our lingering questions. He suggested using Ubuntu since that is the operating system that the ROS api is tested against. He also gave us the robotics kit so that we can begin work on the arm. After getting the kit, I spent an hour or two figuring out how to physically put the arm together, which wires go where, etc. Since we are working on Ubuntu, I tried looking at various IDEs. We initially wanted to use Visual Studio as an IDE; however, since we are developing on Ubuntu and Visual Studio not seem usable on Ubuntu (even with Wine) I found a very similar IDE called MonoDevelop has many of the capabilites of Visual Studio. I also downloaded OpenCV and made an issue with links and some instructions on packages that need to be installed and how to install them.

jcoady9 commented 9 years ago

I started writing code that uses the OpenCV libraries to load and display an image. I also made a makefile to compile and clean our source code. Some skeleton code for a Vertex class was written as well, the functions besides the constructor and destructor have yet be be implemented.

https://github.com/jcoady9/Senior-Design-I/commit/e8b9104a5f9619334237c0db1a58cf079492fab7

jcoady9 commented 9 years ago

This week I continued working on the Vertex class and also created a Line class that will store information on how the line should be drawn. Last week we demonstrated that our program could be given the path to an image and display said image. Now our program can be given an image and the program will detect corners in the image. The program will display the original image and a modified gray-scale version of the image that will have any discovered corners circled.

https://github.com/jcoady9/Senior-Design-I/commit/178961c9589e906b81df6b685b65c8c1969ff49a

jcoady9 commented 9 years ago

Over the past two weeks I have helped Sam finish implementing and debugging code for the detection of lines.

5a98c202454767c7ab6586067ad44a8bd552b242

We found that for each line in the image, the houghLines() method detects several lines for that line. I have since then been trying to find a way to find lines that are in a close proximity to each other so that there would only be one set of coordinates per each line endpoint. To determine whether lines were in close proximity as well as making sure they related to the same line in the image I have worked with this equation in the OpenCV documentation of Hough Lines: http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html

Using rho and theta, I can determine a point that all related lines contain or are in close proximity.

256a84bbad4f34a202d6655fe06f7094757b934e

By finding rho and thetas that are similar, I can then find average rho and thetas that lines can be related to. I began implementing a heapsort algorithm that will help make this a little simpler. The heapsort algorithm is not yet fully complete so I implemented an insertion sort algorithm that can be used until heapsort is fully implemented as heapsort has a better overall runtime.

18fc46d47966eaa19b45ec10848d3b06852b5474

jcoady9 commented 9 years ago

This week I implemented an algorithm I researched online that would thing any lines that were in the image. Since the image processing portion of the project was detecting multiple lines per actual line in the image, I thought that thinning the line would help reduce the number of lines detected. This has been somewhat successful; line thinning combined with corner detection has reduced the number of detected lines by about half. I also modified the lineDetection() method so that it will return a vector of four integer vectors that will contain the coordinates of line endpoints. These coordinates can then be used to create vertices which can then be run through our implementation of DFS and so on and so forth.

f114ec5e8d4583c2b96298ba2782c383282578c1

bd846c69e10041bdd017dbbd7cc0beddcaecad24

jcoady9 commented 9 years ago

I implemented some code that enables us to now detect curved lines in the image that we wish to process. I also helped Shane and Sam this week with some code that simulates our ability to draw an image from vertices. I helped out by showing them some of the opencv libraries that they could use to display the image they were drawing. This shows that we can process an image, create vertices while processing the image and being able to reproduce the image with the vertices created from the source image.

b9c10050985455cdb487287c859453e38ea7808d

jcoady9 commented 9 years ago

This week I worked further on detecting curved lines in the image we want to process. I made a cpp file where I could test the methods used for image processing. This way I can move all the code I wrote for testing inside the methods to a file specifically for testing.

I also got rid of methods in vertexSearch.cpp that we are not using anymore and did not seem to be necessary in the future.

ab0ec9099fb718826a5ab0a782f577447b03471f

I created a directory to store images that I have been using to test the image processing. I figured Sam and Shane could use the images while working on the simulator.

aaeea3f9f98e2231c933d28c8deef902882e1959

I also worked on removing contours that seem to be clustering around the endpoints of lines already detected. I implemented a method to remove contours that have the majority of its points clustering around line endpoints while keeping contours that are not near line endpoints.

08f5ba7d00706adbefc940349b797e429e364b4c

Now that we have a set of usable contours, I converted the vectors of points into vector of Vec4i, the same kind of vector the line endpoint coordinates are stored in. This way all the information on lines and contours can be combined into a single vector.

be5f2ffe921afe9f2928624a066cae3af9b018fa

jcoady9 commented 9 years ago

This week I worked on fixing the bugs with detecting and drawing curved lines. There were several bugs that I fixed. For instance, the first bug I fixed was an issue where some of the line coordinates had negative values. This was a simple mix-up of parameters when calling the method that detects contours.

8e762666371495c02ee158f988bde53e07fd0d61

Another bug I fixed was that the curved lines we were detecting have far too many points in them. For thicker lines, it was detecting a point for each pixel that composed the line. This was solved by checking if a point of a curved line was between the endpoints of a detected straight line.

4d1c93945334338a522c415d9b599268ca2e493c

I also created a .gitignore file so that we do not need to keep re-adding several files to the commit tree each time we make a commit.

d2c288eaa032db7148a2d92f464f46a6c8f0e0ba

Also I changed some method parameters from being cv::Mat to being cv::Mat& references in hopes that it will improve the runtime of the program.

93a79ddef8cde1c273c786e5906b4470bc1e43c0

jcoady9 commented 9 years ago

This week I refactored all the method used in processing an image into drawable lines to be used with a class that specifically handles the image processing. I also started writing unit tests for this class, but the unit tests are not yet fully complete.

8068a767dac476b9036eb586610dc25a55289f58 ed24b19807012c1775b4f7293864b95c1db084ca

I implemented a class call Drawing which was made to store data on the detected lines from the image processing. The method ImageProcessor.processImage() was changed so that it would return a drawing object.

4df092e5a73abc1c578dfafcd5fbdb06a367275b

f62544ba3e05ce8a7925743c2dde4a7f6807c2c5

I also started implementing the subclass of drawImageInterface that will deal will take the drawable lines detected from the image processing and will handle communicating the detected lines to the arbotix robot arm.

fb108f9f4500aa99a015b8254dfa9712f8add736 01a26000f44b17bc7a173c38ab1e796e89f376fc

jcoady9 commented 9 years ago

This week I accomplished writing the unit tests for the ImageProcessor class. I adjusted the scope of most of the classes functions to be public so it would be easier to test them. One of the tests is a visual comparison of an image before and after I process the image with it since I could not think of an easy way to test that the function was doing what it was expected to accomplish.

475dd9758dc2358582fa6308dbfc38bd8b18b1ad

jcoady9 commented 9 years ago

This week I refactored the Vertex class into the Point class since it would make more sense to have a model object that holds Cartesian coordinates to be called point.

ae80f90597ef0377f0a7631eedfe760f85243424

I also modified the ImageProcessor to simplify the detected curved lines. I changed contours from being pixel-by-pixel to being a set of small straight lines to help making drawing the curved line slightly easier.

ec153096d87fb6497d0bb9aa979b6e329ffa0af2

I also helped Sam work on the concepts of inverse kinematics so we can properly draw the source image.