Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 668

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-theme.php on line 544

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/twodee/blog/wp-includes/class-wp-block-list.php on line 199

Deprecated: Creation of dynamic property Automattic\Jetpack\Connection\Manager::$error_handler is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-connection/src/class-manager.php on line 91

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Instagram_Gallery::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-instagram-gallery.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Mailchimp::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-mailchimp.php on line 17

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 21

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Tweetstorm_Gather::$is_wpcom is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-tweetstorm-gather.php on line 22

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Gutenberg_Available_Extensions::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/gutenberg-available-extensions.php on line 20

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 23

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Memberships::$wpcom_is_site_specific_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/memberships.php on line 24

Deprecated: Creation of dynamic property WPCOM_REST_API_V2_Endpoint_Subscribers::$wpcom_is_wpcom_only_endpoint is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/subscribers.php on line 15

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property Automattic\Jetpack\Sync\Queue::$random_int is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-queue.php on line 38

Deprecated: Creation of dynamic property WPCOM_Widget_Goodreads::$shelves is deprecated in /var/www/twodee/blog/wp-content/plugins/jetpack/modules/widgets/goodreads.php on line 33

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/twodee/blog/wp-includes/script-loader.php on line 348

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /var/www/twodee/blog/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: Creation of dynamic property WP_Block_Type::$plan_check is deprecated in /var/www/twodee/blog/wp-includes/class-wp-block-type.php on line 333

Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/twodee/blog/wp-includes/wp-db.php on line 3030

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /var/www/twodee/blog/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Warning: Cannot modify header information - headers already sent by (output started at /var/www/twodee/blog/wp-includes/class-wp-block-list.php:14) in /var/www/twodee/blog/wp-includes/feed-rss2.php on line 8
fish vision – teaching machines https://twodee.org/blog Fri, 15 Mar 2013 14:41:30 +0000 en-US hourly 1 https://wordpress.org/?v=5.7.1 Plotting samples with GNU Octave https://twodee.org/blog/2487 https://twodee.org/blog/2487#respond Fri, 16 Dec 2011 16:11:08 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=2487 Suppose we have a plain text file of samples named samples.txt, with each intensity on its own line:

1
2
3
4
5
4
3
2
1
0
-1
2
3
4
5
4
3
2
1
0
1
2
3
4

We can visualize these results in GNU Octave with:

samples = load('-ascii', 'samples.txt');
plot(samples);

If we write this code in a script named plot_samples.m, we can simply run plot_samples at the Octave command-line.

]]>
https://twodee.org/blog/2487/feed 0
Otolith Threshold and GUI https://twodee.org/blog/2198 https://twodee.org/blog/2198#respond Fri, 18 Nov 2011 17:32:33 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=2198 [...]]]> Winston and I made progress on thresholding the images and getting user input.

The currently committed version takes in a (hard coded) image path and displays the image with a binary threshold, with a check value of 90. In the GUI, there is a slider that allows the user to change the check value to any number between 0 and 255. The image is update in real time. Also, clicking and dragging on the image allows a red line to be drawn across the image. Currently, we limit the user to only one drawing attempt.

The threshold approach works fairly well for lines farther from the center, but quality begins to deteriorate as you move in. We have yet to use the line to calculate the number of rings drawn over and the distances between them.

Here is the current code:

#include <cv.h>
#include <highgui.h>

bool drawingLine,once;
CvPoint p1, p2;
int threshold;

void get_Threshold(IplImage* src, IplImage* dst){
	// Allocate individual image planes
	IplImage* r = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U, 1);
	IplImage* g = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U, 1);
	IplImage* b = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U, 1);

	//Split image on the color plane
	cvSplit(src,r,g,b,NULL);

	//Temporary storage
	IplImage* s = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1);

	//Add equally weighted rgb values
	cvAddWeighted(r, 1./3., g, 1./3., 0.0, s);
	cvAddWeighted(s, 2./3., b, 1./3., 0.0, s);

	//Threshold
	cvThreshold(s,dst,threshold,255,CV_THRESH_BINARY);

	cvReleaseImage(&r);
	cvReleaseImage(&g);
	cvReleaseImage(&b);
	cvReleaseImage(&s);
}

void my_mouse_callback(int event, int x, int y, int flags, void* img){
	IplImage* image = (IplImage*) img;

	switch(event){
	//Update endpoint if the line is being drawn. Only allow one line.
	case CV_EVENT_MOUSEMOVE:{
		if(drawingLine && !once){
			p2 = cvPoint(x,y);
		}
	}
	break;		
	//Set the line points and start drawing as long as we haven't already
	//drawn a line
	case CV_EVENT_LBUTTONDOWN:{
		if(!once){
		drawingLine = true;
		p1 = cvPoint(x,y);
		p2 = cvPoint(x,y);
		}
	}
	break;
	//and the line and prevent future lines from being drawn
	case CV_EVENT_LBUTTONUP:{
		if(!once){
		p2 = cvPoint(x,y);
		drawingLine = false;
		}
		once = true;
	}
	break;
	}

}
//update the image threshold from trackbar
void on_change(int pos){
	threshold = pos;
}

int main(int argc, char **argv)
{	//initialize
	threshold = 90;
	IplImage* img = cvLoadImage("C:\\Users\\Corey\\Pictures\\Fish_Research\\FCM060-2fL.jpeg");
	IplImage* dst = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U, 1);
	drawingLine = false;
	once = false;

	//Holds the tresholded image
	IplImage* thresholdGray = cvCreateImage(cvGetSize(dst),IPL_DEPTH_8U,1);
	//holds the color version of the thresholded image so color lines can be drawn on top
	IplImage* thresholdColor = cvCreateImage(cvGetSize(dst),IPL_DEPTH_8U,3);

	//create the gui
	cvNamedWindow("Otolith",0);
	cvMoveWindow("Otolith",0,0);
	cvResizeWindow("Otolith",cvGetSize(img).width,cvGetSize(img).height);
	cvCreateTrackbar("Threshold","Otolith",&threshold,255,on_change);
	cvSetMouseCallback("Otolith",my_mouse_callback, (void*)dst); 
	//run until user hits Esc
	while(1){
		//threshold the image
		get_Threshold(img,thresholdGray);

		//create the colored version
		cvMerge(thresholdGray,thresholdGray,
                        thresholdGray,NULL,thresholdColor);

		//draw the line if needed
		if(drawingLine || once){
			cvLine(thresholdColor,p1,p2,CV_RGB(255,0,0),2,8,0);
		}

		//show the image
		cvShowImage("Otolith", thresholdColor);
		
		//check for key press
		if(cvWaitKey(15)==27) break;
	}
	cvReleaseImage(&img);
	cvReleaseImage(&dst);
	cvReleaseImage(&thresholdGray);
	cvReleaseImage(&thresholdColor);
	cvDestroyWindow("Otolith");
	return 0;
}
]]>
https://twodee.org/blog/2198/feed 0
Canny Algorithm edge detection https://twodee.org/blog/1737 https://twodee.org/blog/1737#respond Tue, 01 Nov 2011 13:51:52 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=1737 [...]]]> Last week I started reading sections of the OpenCV book given to me by Professor Johnson and Stevenson. The sections I read with had to deal with edge detection and gray scaling (required for the Canny Algorithm). I expanded upon my previous code for loading in an image to do this.

 

// OpenCVConfiguration.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>


int main(int argc, char *argv[])
{
	//image loading and allocation to memory
	//IplImage* img = cvLoadImage( "S:\\Photos\\Television\\Pokemon\\pokemon.jpg" );

	//window creation
	//cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );

	//load image to window
	//cvShowImage( "Example1", img );

	//wait key causes a pause for a keystroke determined by the parameter
	//0 = indefinite wait
	//cvWaitKey( 0 );
	//without this the window seems to close instantly

	//release the memory of the image
	//cvReleaseImage( &img );

	//deallocate the window memory
	//cvDestroyWindow( "Example1" );

	//image loading and allocation to memory
	IplImage* img = cvLoadImage( "S:\\Photos\\Fish Vision\\FCM060-2FL.jpeg" );
	//IplImage* img = cvLoadImage( "S:\\Photos\\Television\\Pokemon\\pokemon.jpg" );

	//window creation
	cvNamedWindow( "Original", CV_WINDOW_AUTOSIZE );

	//load image to window
	cvShowImage( "Original", img );

	//without this the window seems to close instantly

	//Try to grayscale image
	
	//was going to copy image did not work as planned, just going to create a new image
	//IplImage* img2 = cvCopy( img );
	//does not work requires array does not take iplimage
	//cvCvtColor() 

	//instead create new image to convert to grayscale
	//IplImage* img2 = cvCreateImage( cvSize( img->width, img->height ), img->depth, img->nChannels );
	IplImage* img2 = cvLoadImage("S:\\Photos\\Fish Vision\\FCM060-2FL.jpeg",CV_LOAD_IMAGE_GRAYSCALE);
	//IplImage* img2 = cvLoadImage("S:\\Photos\\Television\\Pokemon\\pokemon.jpg",CV_LOAD_IMAGE_GRAYSCALE);

	//cvCvtColor( img, img2, CV_RGB2GRAY );

	//window creation
	cvNamedWindow( "Grayscale", CV_WINDOW_AUTOSIZE );

	//load image to window
	cvShowImage( "Grayscale", img2 );

	// expects (img, output img, low threshold, high threshold, aperture?) //images must be grayscale
	cvCanny( img2, img2, 10, 100, 3  );

	//window creation
	cvNamedWindow( "Canny Edge Detection", CV_WINDOW_AUTOSIZE );

	//load image to window
	cvShowImage( "Canny Edge Detection", img2 );

	//wait key causes a pause for a keystroke determined by the parameter
	//0 = indefinite wait
	cvWaitKey( 0 );

	//release the memory of the image
	cvReleaseImage( &img );
	cvReleaseImage( &img2 );

	//deallocate the window memory
	cvDestroyWindow( "Original" );
	cvDestroyWindow( "Grayscale" );
	cvDestroyWindow( "Canny Edge Detection" );

	return 0;
}

I have left the comments in to show some of my thought process. The next step is to get tortoise svn up and running. I have installed and will be learning how to use it with Cmake.
]]>
https://twodee.org/blog/1737/feed 0
Project configuration https://twodee.org/blog/1698 https://twodee.org/blog/1698#respond Tue, 25 Oct 2011 21:26:32 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=1698 [...]]]> While waiting to hear back from ORSP, we are taking the time to find a sustainable solution for managing our project across multiple platforms and machines. We really want to share code without emailing it. We also want to avoid fiddling with Visual Studio as much as possible. For this, we’ve chosen to use TortoiseSVN and CMake.

Here are the steps we take to set up a new Windows machine and a Visual Studio project:

Setup

  1. Install TortoiseSVN.
  2. Right-click on the directory where you’d like to check out the code repository. Choose SVN Checkout. Enter https://host:port/svn/otolith/trunk for the URL. Hit OK. Wait for the files to download. Since I included OpenCV in the project itself, it will take a couple of years to grab everything.
  3. Install CMake.
  4. Run CMake from the start menu. Enter the checked out trunk directory as the source directory. Enter a build directory outside the source directory. Hit Configure. Choose Visual Studio 10, native compilers. Hit Generate. Close CMake.
  5. The build directory contains OTOLITH.sln, your Visual Studio solution file. Open it.
  6. There’s a project listed for every component of the OpenCV library, plus for all of our stuff. In order to switch back and forth between these, right-click on the solution node in the Solution Explorer, choose Set Startup Projects, and select Current Selection under Common Properties, Startup Project.
  7. Switch to Release mode. This step shouldn’t be necessary, but staying in Debug mode produces a “This application could not start properly” error message.
  8. Select your project and run it. It’ll build all the OpenCV stuff and any of our code that we’ve registered with CMake.

Workflow

  1. Right-click on the checkout directory and SVN Update.
  2. Edit code, add files, tweak CMakeLists.txt.
  3. Right-click on the checkout directory and SVN Commit.

Adding a new executable

  1. Open checkout/username/CMakeLists.txt.
  2. Add some lines like:
    add_executable(my_executable source1.cpp source2.cpp ...)
    target_link_libraries(my_executable ${OpenCV_LIBS})

Adding source files to executable/project

  1. Either in Visual Studio:
    1. Expand the project in Visual Studio.
    2. Right-click on Source Files and choose Add.
    3. Pick the file type.
    4. Change the location to your directory in the checkout folder.  By default it places the new file in the build directory.

    or in Windows Explorer:

    1. Create the file in your directory.
  2. In Windows Explorer, right-click on the new file and Add it with TortoiseSVN. (Don’t forget to commit when done!)
  3. Augment the executable dependencies in the appropriate add_executable call in CMakeLists.txt.
]]>
https://twodee.org/blog/1698/feed 0
OpenCV Set Up https://twodee.org/blog/1300 https://twodee.org/blog/1300#respond Mon, 17 Oct 2011 05:23:01 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=1300 [...]]]> After several tutorial tries, I was able to install it successfully on windows with the same tutorial install of OpenCV that Corey used.

The step by step process is listed in the following link:  http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/

I then started to play around with the libraries. I was able to load in an image to a window.

 

// OpenCVConfiguration.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>

int main(int argc, char *argv[])
{
	IplImage* img = cvLoadImage( "S:\\Photos\\Television\\Pokemon\\pokemon.jpg" );
	cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
	cvShowImage( "Example1", img );
	cvWaitKey( 0 );
	cvReleaseImage( &img );
	return 0;
}

 

I do not have a webcam on my current computer to test video capture. I am going to attempt to get an IDE for my laptop to try this code. In the next few days I will attempt to code some edge detection for the images sent to me by Professor Johnson.

 

 

 

]]>
https://twodee.org/blog/1300/feed 0
Installing OpenCV on Linux https://twodee.org/blog/1277 https://twodee.org/blog/1277#respond Thu, 13 Oct 2011 11:58:36 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
http://www.twodee.org/blog/?p=1277 [...]]]> I was able to get OpenCV installed without too much trouble on my Ubuntu Linux machine. A simple

sudo apt-get install libcv-dev

did the trick. I tested the installation by writing a short C program to pop up an image:

#include <opencv/highgui.h>
#include <stdio.h>

int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s path/to/image", argv[0]);
    exit(1);
  }

  char *path = argv[1];

  IplImage *img = cvLoadImage(path);
  cvNamedWindow(path, CV_WINDOW_AUTOSIZE);
  cvShowImage(path, img);
  cvWaitKey(0);
  cvReleaseImage(&img);
  cvDestroyWindow(path);

  return 0;
}

To test video playback and webcam capturing, I wrote another little program to play a video frame-by-frame:

#include <iostream>
#include <opencv/highgui.h>

int main(int argc, char **argv) {
  CvCapture *movie;
  char *path;

  // Get frames from movie if one provided. Webcam otherwise.
  if (argc > 1) {
    movie = cvCreateFileCapture(argv[1]);
    path = argv[1];
  } else {
    movie = cvCreateCameraCapture(0);
    path = strdup("camera");
  }

  cvNamedWindow(path, CV_WINDOW_AUTOSIZE);
  IplImage *frame;

  // Play movie one frame at a time, advancing only when a non-Escape
  // key is pressed. Hit Escape to escape.
  char c = '\0';
  frame = cvQueryFrame(movie);
  while (frame && c != 27) {
    cvShowImage(path, frame);
    c = cvWaitKey(0);
    frame = cvQueryFrame(movie);
  }

  cvReleaseCapture(&movie);
  cvDestroyWindow(path);

  return 0;
}

I compiled these at the shell with:

gcc -o image image.cpp -lcv -lhighgui
gcc -o framer framer.cpp -lcv -lhighgui

Installation on Linux was pleasant.

]]>
https://twodee.org/blog/1277/feed 0