<commit_before>package opencv

import (
	"testing"
)

func TestLoadImage2(t *testing.T) {
	// t.Errorf("aaa")
}

<commit_msg>Create start of testing of cxcore functions<commit_after>package opencv

import (
	"testing"
	"fmt"
)

func TestContourArea(t *testing.T){
	img := CreateImage(100,100,IPL_DEPTH_8U,1)
	defer img.Release()
	// Creating object of area 100
	shape := []Point{
		Point{10,10}, 
		Point{20,10},
		Point{20,20},
		Point{10,20},
		Point{10,10}}
	for i:=0; i<(len(shape)-1); i++{
		Line(img, shape[i], shape[i+1], ScalarAll(255), 1, 8, 0)		
	}
	c,n := FindContours(img, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, nil)
	fmt.Printf("Found %d contours\n", n)
	a := ContourArea(c, 0)
	fmt.Printf("Area of contour is %v \n", a)
	p := ArcLength(c,0)
	fmt.Printf("Perimeter of contour is %v \n", p)
}

func TestConvexityDefects(t *testing.T) {
	img := CreateImage(100,100,IPL_DEPTH_8U,1)
	defer img.Release()
	// Object with convex defect of 10 and 3
	shape := []Point{
		Point{10,10}, 
		Point{20,10},
		Point{20,20},
		Point{30,20},
		Point{30,10}, 
		Point{40,10}, 
		Point{40,40},
		Point{30,40},
		Point{30,37},
		Point{20,37},
		Point{20,40},
		Point{10,40},
		Point{10,10}}
	for i:=0; i<(len(shape)-1); i++{
		Line(img, shape[i], shape[i+1], ScalarAll(255), 1, 8, 0)		
	}
	c,n := FindContours(img, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, nil)
	fmt.Printf("Found %d contours\n", n)
	a := ContourArea(c, 0)
	fmt.Printf("Area of contour is %v \n", a)
	p := ArcLength(c,0)
	fmt.Printf("Perimeter of contour is %v \n", p)
	d, n2 := ConvexityDefects(c, 0)
	fmt.Printf("Found %d defects\n", n2)
	for i:=0; i<n2; i++{
		fmt.Printf("Found defect of size %v \n", d[i])
	}
}


{'fraction_non_alphanumeric': 0.19200954084675015, 'fraction_numerical': 0.0727489564698867, 'mean_word_length': 4.395498392282958, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6235275', 'n_tokens_mistral': 851, 'n_tokens_neox': 751, 'n_words': 165}