commit fe02faa9b9e5564ee41c0379e0fbdb4d87385716 Author: Денис Кузнецов Date: Sun Mar 3 16:04:22 2024 +0300 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f410d5c --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +lib/ +ImageDraw/ +packages/ +ipch/ +*.zip +*.pdf +*.rar +*.txt +*.pdb +obj/ +Debug/ +*.html +*.*~ +*.suo +*.sdf +.vs/ diff --git a/1.bmp b/1.bmp new file mode 100644 index 0000000..6f3cd76 Binary files /dev/null and b/1.bmp differ diff --git a/2.bmp b/2.bmp new file mode 100644 index 0000000..6f3cd76 Binary files /dev/null and b/2.bmp differ diff --git a/3.bmp b/3.bmp new file mode 100644 index 0000000..2f0ebef Binary files /dev/null and b/3.bmp differ diff --git a/32002400.bmp b/32002400.bmp new file mode 100644 index 0000000..069dd35 Binary files /dev/null and b/32002400.bmp differ diff --git a/320256.bmp b/320256.bmp new file mode 100644 index 0000000..f490426 Binary files /dev/null and b/320256.bmp differ diff --git a/AxisX.png b/AxisX.png new file mode 100644 index 0000000..574d724 Binary files /dev/null and b/AxisX.png differ diff --git a/CanvasElement.png b/CanvasElement.png new file mode 100644 index 0000000..438138f Binary files /dev/null and b/CanvasElement.png differ diff --git a/CheckBoxChecked.png b/CheckBoxChecked.png new file mode 100644 index 0000000..c32c15f Binary files /dev/null and b/CheckBoxChecked.png differ diff --git a/CheckBoxUnchecked.png b/CheckBoxUnchecked.png new file mode 100644 index 0000000..9814763 Binary files /dev/null and b/CheckBoxUnchecked.png differ diff --git a/ConsoleApplication1.exe b/ConsoleApplication1.exe new file mode 100644 index 0000000..a3e599b Binary files /dev/null and b/ConsoleApplication1.exe differ diff --git a/ConsoleApplication1/ConsoleApplication1.cpp b/ConsoleApplication1/ConsoleApplication1.cpp new file mode 100644 index 0000000..e254289 --- /dev/null +++ b/ConsoleApplication1/ConsoleApplication1.cpp @@ -0,0 +1,1452 @@ +// ConsoleApplication1.cpp: . +// +#define _AFXDLL +#include "stdafx.h" +//#include "afxwin.h" +#include +#include +#include +#include +#include +#include +#include "main.h" +#include +#include + +using namespace std; + +typedef unsigned char U8; +typedef signed char S8; +typedef unsigned short U16; +typedef signed short S16; +typedef unsigned int U32; +typedef signed int S32; +typedef bool BIT; + +#define POROG 50 +#define M_PI 3.14159265358979323846 + +//int load_image(_TCHAR *fname, FIFO_ITEM *ff1, U16 &k1); +int load_image2(_TCHAR *fname, FIFO_ITEM *ff1, U16 &k1); +void ssaimage(_TCHAR *fname, int num); +void bcaimage(_TCHAR *fname, int num); +void bcaimage2(_TCHAR *fname, int num); +void eicimage(_TCHAR *fname, int num); +void cmcimage(_TCHAR *fname, int num, U16 x, U16 y); +void cmcimage2(_TCHAR *fname, FIFO_ITEM_f *centr, U16 num, U8 array); + +void drawrect(CImage *im, U16 l, U16 t, U16 r, U16 b, COLORREF color); +void drawcircle(CImage *im, U16 x, U16 y, U16 r, COLORREF color); +void drawrectsolid(CImage *im, U16 l, U16 t, U16 r, U16 b, COLORREF color); + +static void store_shot_array1(BIT use_extended_field_of_view); +static void store_shot_array2(BIT use_extended_field_of_view); +static void build_clusters_array1(void); +static void build_clusters_array2(void); +static void exclude_intersected_clusters_from_array1(void); +static void exclude_intersected_clusters_from_array2(void); +static void enlarge_clusters_in_array1(void); +static void enlarge_clusters_in_array2(void); +static BIT calculate_mass_centre_by_array1(float *px, float *py); +static BIT calculate_mass_centre_by_array2(float *px, float *py); +static BIT calculate_mass_centre(FIFO_ITEM_f *mass, U16 *num, U8 array); +static BIT cmcentre(U8 array); + +static U64 get_time_10us(void); +U16 get_coords_count(void); +BIT pop_coords_item(COORDS_DATA *coords); +BIT push_coords_item(const COORDS_DATA *coords); +static void calculate_angles(float x, float y, S16 *pAngle1, S16 *pAngle2); + +__inline void CopyRect(ARM_RECT *dst, const ARM_RECT *src) +{ + dst->left = src->left; + dst->top = src->top; + dst->right = src->right; + dst->bottom = src->bottom; +} +__inline BIT EmptyRect(const ARM_RECT *r) +{ + return !(((S32)r->right - (S32)r->left) > 0 && + ((S32)r->bottom - (S32)r->top) > 0); +} +__inline BIT IntersectRect(ARM_RECT *r, const ARM_RECT *r1, const ARM_RECT *r2) +{ + ARM_RECT rect; + + CopyRect(&rect, r1); + + if (r2->left > r1->left) rect.left = r2->left; + if (r2->top > r1->top) rect.top = r2->top; + if (r2->right < r1->right) rect.right = r2->right; + if (r2->bottom < r1->bottom) rect.bottom = r2->bottom; + + if (r) + *r = rect; + + return !EmptyRect(&rect); +} +__inline void make_point(FIFO_ITEM *pi, U8 *pm, THE_POINT *point) +{ + point->pi = pi; + point->pm = pm; +} +__inline BIT neighbour_points(const THE_POINT *p1, const THE_POINT *p2, U8 length) +{ + return (abs((S16)p2->pi->x - (S16)p1->pi->x) <= length) && (abs((S16)p2->pi->y - (S16)p1->pi->y) <= length); +} +__inline BIT point_has_no_marker(const THE_POINT *p) +{ + return *(p->pm) == NO_MARKER; +} +__inline void copy_marker(THE_POINT *dst, const THE_POINT *src) +{ + *(dst->pm) = *(src->pm); +} +static unsigned short read_u16(FILE *fp) +{ + unsigned char b0, b1; + + b0 = getc(fp); + b1 = getc(fp); + + return ((b1 << 8) | b0); +} +static unsigned int read_u32(FILE *fp) +{ + unsigned char b0, b1, b2, b3; + + b0 = getc(fp); + b1 = getc(fp); + b2 = getc(fp); + b3 = getc(fp); + + return ((((((b3 << 8) | b2) << 8) | b1) << 8) | b0); +} +static int read_s32(FILE *fp) +{ + unsigned char b0, b1, b2, b3; + + b0 = getc(fp); + b1 = getc(fp); + b2 = getc(fp); + b3 = getc(fp); + + return ((int)(((((b3 << 8) | b2) << 8) | b1) << 8) | b0); +} + +vector v1, v2; + +int _tmain(int argc, _TCHAR* argv[]) +//int _tmain(int argc, char* argv[]) +{ + USES_CONVERSION; + if (argc < 3) + { + printf("Error! Need two parameters! image1 image2 \r\n"); + return 1; + } + + string fn1 = W2A(argv[1]); + string fn2 = W2A(argv[2]); + + CString t1 = argv[1]; + CString t2 = _T("asdfgh"); + CString t3 = t1 + t2; +// t3. + +// printf("%s %s\r\n", t1, t2); + cout << "- " << W2A(t3) << " - " << t2 << " -" << endl; + + FIFO_ITEM f1[4096] = { 0 }; + U16 num1 = 0; + FIFO_ITEM f2[4096] = { 0 }; + U16 num2 = 0; + + load_image2(argv[1], f1, num1); + load_image2(argv[2], f2, num2); + + for (int i = 0; i < num1; i++) + { + printf("%d\t- %d.%d\n",i, f1[i].x, f1[i].y); + v1.push_back(f1[i]); + } + cout << "Pixels 1 = " << num1 << endl; + cout << "Pixels 2 = " << v1.size() << endl; + for (int i = 0; i < num2; i++) + { + printf("%d\t- %d.%d\n", i, f2[i].x, f2[i].y); + v2.push_back(f2[i]); + } + cout << "Pixels 2 = " << num2 << endl; + cout << "Pixels 2 = " << v2.size() << endl; + + g_config1.nXc = 157; + g_config1.nYc = 128; + g_config1.nRs = 120; + g_config1.nRb = 122; + g_config1.cLc = 5; + g_config1.fA = 1.64939992828295E-05; + g_config1.fB = -0.00147799996193498; + g_config1.fC = 0.667499005794525; + g_config2.nXc = 157; + g_config2.nYc = 128; + g_config2.nRs = 120; + g_config2.nRb = 122; + g_config2.cLc = 5; + g_config2.fA = 1.64939992828295E-05; + g_config2.fB = -0.00147799996193498; + g_config2.fC = 0.667499005794525; + + BIT ok, ok2; + BIT second_pass_flag; + S16 angle1, angle2; + float x = 0, y = 0; + COORDS_DATA coords; + U32 start_time = 0; + U32 cur_time; + FIFO_ITEM_f centers[10] = { 0 }; + U16 num_shoot = 0; + + // + + second_pass_flag = __FALSE; + + for (int i = 0; i < 2; i++) + { + BIT extended_field_of_view = second_pass_flag; + + store_shot_array1(extended_field_of_view); + store_shot_array2(extended_field_of_view); + + ssaimage(argv[1], 1); + ssaimage(argv[2], 2); + + build_clusters_array1(); + build_clusters_array2(); + + bcaimage(argv[1], 1); + bcaimage(argv[2], 2); + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + bool CMOS1_RKS_CMD_REG = true; + bool CMD_TIMER_CAPTURED_BIT = true; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + if (CMOS1_RKS_CMD_REG & CMD_TIMER_CAPTURED_BIT) // CMOS1 has captured a shot + { + enlarge_clusters_in_array2(); + bcaimage2(argv[2], 2); + + exclude_intersected_clusters_from_array1(); + eicimage(argv[1], 1); + + ok = calculate_mass_centre_by_array1(&x, &y); + cmcimage(argv[1], 1, x, y); + + ok2 = calculate_mass_centre(centers, &num_shoot, 1); + cmcimage2(argv[1], centers, num_shoot, 1); + cmcentre(1); + } + else // CMOS2 has captured a shot + { + enlarge_clusters_in_array1(); + bcaimage2(argv[1], 1); + + exclude_intersected_clusters_from_array2(); + eicimage(argv[2], 2); + + ok = calculate_mass_centre_by_array2(&x, &y); + cmcimage(argv[2], 2, x, y); + + ok2 = calculate_mass_centre(centers, &num_shoot, 2); + cmcimage2(argv[2], centers, num_shoot, 2); + cmcentre(2); + } +/* + if (ok) + { + // XY-coordinates have been successfully calculated, + // now calculate angles + calculate_angles(x, y, &angle1, &angle2); + + coords.time = (U32)get_time_10us(); + coords.angle1 = angle1; + coords.angle2 = angle2; + + push_coords_item(&coords); + + break; + } +*/ + if (ok2) + { + calculate_angles(x, y, &angle1, &angle2); + cout << "Common mass center = " << angle1 << " " << angle2 << endl; + for (int i = 0; i < num_shoot; i++) + { + calculate_angles(centers[i].x, centers[i].y, &angle1, &angle2); + cout << "Mass center = " << angle1 << " " << angle2 << endl; + coords.time = (U32)get_time_10us(); + coords.angle1 = angle1; + coords.angle2 = angle2; + push_coords_item(&coords); + } + + break; + } + + // if couldn't calculate mass center, try to do it again using + // extended field of view in 2-nd processing pass + second_pass_flag = __TRUE; + } + + + return 0; +} +/* +int load_image(_TCHAR *fname, FIFO_ITEM *ff1, U16 &k1) +{ + USES_CONVERSION; + FILE * pFile1 = fopen(W2A(fname), "rb"); + + // + cout << "Load " << W2A(fname) << endl; + // BITMAPFILEHEADER header; + BFHEADER header1; + + header1.bfType = read_u16(pFile1); + header1.bfSize = read_u32(pFile1); + header1.bfReserved1 = read_u16(pFile1); + header1.bfReserved2 = read_u16(pFile1); + header1.bfOffBits = read_u32(pFile1); + + cout << "Size " << header1.bfSize << endl; + + // + // BITMAPINFOHEADER bmiHeader; + BIHEADER bmiHeader1; + + bmiHeader1.biSize = read_u32(pFile1); + bmiHeader1.biWidth = read_s32(pFile1); + bmiHeader1.biHeight = read_s32(pFile1); + bmiHeader1.biPlanes = read_u16(pFile1); + bmiHeader1.biBitCount = read_u16(pFile1); + bmiHeader1.biCompression = read_u32(pFile1); + bmiHeader1.biSizeImage = read_u32(pFile1); + bmiHeader1.biXPelsPerMeter = read_s32(pFile1); + bmiHeader1.biYPelsPerMeter = read_s32(pFile1); + bmiHeader1.biClrUsed = read_u32(pFile1); + bmiHeader1.biClrImportant = read_u32(pFile1); + + cout << "Width " << bmiHeader1.biWidth << endl; + cout << "Height " << bmiHeader1.biHeight << endl; + + RGBQ **rgb1 = new RGBQ*[bmiHeader1.biWidth]; + for (int i = 0; i < bmiHeader1.biWidth; i++) + { + rgb1[i] = new RGBQ[bmiHeader1.biHeight]; + } + + for (int i = 0; i < bmiHeader1.biWidth; i++) + { + for (int j = 0; j < bmiHeader1.biHeight; j++) + { + rgb1[i][j].rgbBlue = getc(pFile1); + rgb1[i][j].rgbGreen = getc(pFile1); + rgb1[i][j].rgbRed = getc(pFile1); + } + // + getc(pFile1); + } + + fclose(pFile1); + +// ff1[4096] = { 0 }; +// k1 = 0; + // + for (int i = 0; i < bmiHeader1.biWidth; i++) + { + for (int j = 0; j < bmiHeader1.biHeight; j++) + { + if (rgb1[i][j].rgbRed > POROG && rgb1[i][j].rgbGreen > POROG && rgb1[i][j].rgbBlue > POROG) + { +// printf("%d.%d %d %d %d\n", i, j, rgb1[i][j].rgbRed, rgb1[i][j].rgbGreen, rgb1[i][j].rgbBlue); + ff1[k1].x = i; + ff1[k1++].y = j; +// printf("%d.%d\n", ff1[k1-1].x, ff1[k1-1].y); + } + } + } + + cout << "FIFO " << k1 << endl; + cout << "Load OK " << W2A(fname) << endl; + return 0; +} + +*/ +int load_image2(_TCHAR *fname, FIFO_ITEM *ff1, U16 &k1) +{ + USES_CONVERSION; + CImage ci; + ci.Load(fname); + for (int i = 0; i < 100; i++) + { + ci.SetPixel(i, i, RGB(255, 0, 0)); + } + for (int i = 100; i < 200; i++) + { + ci.SetPixel(i, i, RGB(0, 255, 0)); + } + for (int i = 0; i < 100; i++) + { + ci.SetPixel(50, i, RGB(0, 255, 255)); + } + for (int i = 0; i < 100; i++) + { + ci.SetPixel(i, 50, RGB(255, 0, 255)); + } + + for (int i = 0; i < 319; i++) + { + for (int j = 0; j < 255; j++) + { + COLORREF cr = ci.GetPixel(i, j); + if (GetRValue(cr) > POROG && GetGValue(cr) > POROG && GetBValue(cr) > POROG) + { + // printf("%d.%d %d %d %d\n", i, j, rgb1[i][j].rgbRed, rgb1[i][j].rgbGreen, rgb1[i][j].rgbBlue); + ff1[k1].x = i; + ff1[k1++].y = j; + // printf("%d.%d\n", ff1[k1-1].x, ff1[k1-1].y); + } + } + } + ci.Destroy(); + + // + + cout << "FIFO " << k1 << endl; + return 0; +} + +static void store_shot_array1(BIT use_extended_field_of_view) +{ + U16 i = 0; + U16 x, y; + S32 dx, dy, r; + + cout << "store_shot_array1" << endl; + + g_shot_count1 = 0; + while (!v1.empty()) + { + BIT pixel_is_bad = __FALSE; + BIT pixel_out_of_view = __FALSE; + + FIFO_ITEM pnt = v1.front(); + v1.erase(v1.begin()); + x = pnt.x + FIFO_X_OFFSET; + y = pnt.y + FIFO_Y_OFFSET; + + // try to find pixel in bad pixels array +/* + for (i = 0; i < g_bad_pixels1.count; i++) + { + if (x == g_bad_pixels1.array[i].x && y == g_bad_pixels1.array[i].y) + { + pixel_is_bad = __TRUE; + break; + } + } +*/ + // check if pixel is out of view + dx = (S32)x - (S32)g_config1.nXc; + dy = (S32)y - (S32)g_config1.nYc; + + // select field-of-view radius for processing + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + bool CMOS1_RKS_CMD_REG = true; + bool CMD_TIMER_CAPTURED_BIT = true; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + if (use_extended_field_of_view == __FALSE) + r = (CMOS1_RKS_CMD_REG & CMD_TIMER_CAPTURED_BIT ? g_config1.nRs : g_config1.nRb); // standard field-of-view + else + r = (CMOS1_RKS_CMD_REG & CMD_TIMER_CAPTURED_BIT ? g_config1.nRb : g_config1.nRb + 1); // extended field-of-view + // check if shot is out of field-of-view + if ((dx*dx + dy*dy) > r*r) + { + pixel_out_of_view = __TRUE; + printf("%d - pnt %d.%d xy %d.%d dxdy %d.%d outview\r\n", i, pnt.x, pnt.y, x, y, dx, dy); + } + else + { + printf("%d - pnt %d.%d xy %d.%d dxdy %d.%d\r\n", i, pnt.x, pnt.y, x, y, dx, dy); + } + + // store pixel if not in bad & not out of view + if (!pixel_is_bad && !pixel_out_of_view) + { + g_shot_array1[g_shot_count1].x = x; + g_shot_array1[g_shot_count1].y = y; +// cout << g_shot_count1 << "\t- " << g_shot_array1[g_shot_count1].x << " " << g_shot_array1[g_shot_count1].y << endl; + g_shot_count1++; + } + i++; + } + cout << g_shot_count1 << " pix in g_shot_array1" << endl; +} +static void store_shot_array2(BIT use_extended_field_of_view) +{ + U16 i = 0; + U16 x, y; + S16 __x, __y; + S32 dx, dy, r; + + cout << "store_shot_array2" << endl; + + g_shot_count2 = 0; + while (!v2.empty()) + { + BIT pixel_is_bad = __FALSE; + BIT pixel_out_of_view = __FALSE; + + FIFO_ITEM pnt = v2.front(); + v2.erase(v2.begin()); + x = pnt.x + FIFO_X_OFFSET; + y = pnt.y + FIFO_Y_OFFSET; + + // try to find pixel in bad pixels array +/* + for (i = 0; i < g_bad_pixels2.count; i++) + { + if (x == g_bad_pixels2.array[i].x && y == g_bad_pixels2.array[i].y) + { + pixel_is_bad = __TRUE; + break; + } + } +*/ + // check if pixel is out of view + dx = (S32)x - (S32)g_config2.nXc; + dy = (S32)y - (S32)g_config2.nYc; + // select field-of-view radius for processing + + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + bool CMOS2_RKS_CMD_REG = true; + bool CMD_TIMER_CAPTURED_BIT = true; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + if (use_extended_field_of_view == __FALSE) + r = (CMOS2_RKS_CMD_REG & CMD_TIMER_CAPTURED_BIT ? g_config2.nRs : g_config2.nRb); // standard field-of-view + else + r = (CMOS2_RKS_CMD_REG & CMD_TIMER_CAPTURED_BIT ? g_config2.nRb : g_config2.nRb + 1); // extended field-of-view + + // check if shot is out of field-of-view + // convert XY-coords from CMOS2 to CMOS1 sensor coords + __x = (S16)x - (S16)g_config2.nXc + (S16)g_config1.nXc; + __y = (S16)y - (S16)g_config2.nYc + (S16)g_config1.nYc; + + if ((dx*dx + dy*dy) > r*r) + { + pixel_out_of_view = __TRUE; + printf("%d - pnt %d.%d xy %d.%d dxdy %d.%d _xy %d.%d outview\r\n", i, pnt.x, pnt.y, x, y, dx, dy); + } + else + { + printf("%d - pnt %d.%d xy %d.%d dxdy %d.%d _xy %d.%d\r\n", i, pnt.x, pnt.y, x, y, dx, dy, __x, __y); + } + + + // store pixel if not in bad & not out of view + if (!pixel_is_bad && !pixel_out_of_view && __x > 0 && __y > 0) + { + g_shot_array2[g_shot_count2].x = (U16)__x; + g_shot_array2[g_shot_count2].y = (U16)__y; +// cout << g_shot_count2 << "\t- " << g_shot_array2[g_shot_count2].x << " " << g_shot_array2[g_shot_count2].y << endl; + g_shot_count2++; + } + i++; + } + cout << g_shot_count2 << " pix in g_shot_array2" << endl; +} + +static void build_clusters_array1(void) +{ + U8 marker; + U16 i, j, k, count; + U16 l, t, r, b; + + cout << "build_clusters_array1" << endl; + + memset(g_cluster_coords1, 0, sizeof(g_cluster_coords1)); + + for (i = 0; i < g_shot_count1; i++) + { + FIFO_ITEM *fi = &g_shot_array1[i]; + U16 x = fi->x / CELL_SIZE; + U16 y = fi->y / CELL_SIZE; + CLUSTER_COORD *pcc = &g_cluster_coords1[y*IMAGE_CELL_CX + x]; + + pcc->count++; + pcc->excluded = __FALSE; + pcc->marker = NO_MARKER; + pcc->rect.left = (x)* CELL_SIZE; + pcc->rect.top = (y)* CELL_SIZE; + pcc->rect.right = (x + 1) * CELL_SIZE; + pcc->rect.bottom = (y + 1) * CELL_SIZE; + } + + memset(g_cluster_ptrs1, 0, sizeof(g_cluster_ptrs1)); + + g_cluster_count1 = 0; + for (i = 0; i < IMAGE_CELL_CX*IMAGE_CELL_CY; i++) + { + if (g_cluster_coords1[i].count > 0) + g_cluster_ptrs1[g_cluster_count1++] = &g_cluster_coords1[i]; + } + + marker = NO_MARKER; + for (i = 0; i < g_cluster_count1; i++) + { + CLUSTER_COORD *pcc1 = g_cluster_ptrs1[i]; + S16 x1 = (pcc1->rect.left + pcc1->rect.right) / 2; + S16 y1 = (pcc1->rect.top + pcc1->rect.bottom) / 2; + + if (pcc1->marker == NO_MARKER) + pcc1->marker = (++marker); + + for (j = i + 1; j < g_cluster_count1; j++) + { + CLUSTER_COORD *pcc2 = g_cluster_ptrs1[j]; + S16 x2 = (pcc2->rect.left + pcc2->rect.right) / 2; + S16 y2 = (pcc2->rect.top + pcc2->rect.bottom) / 2; + + if (abs(x1 - x2) <= CELL_SIZE && abs(y1 - y2) <= CELL_SIZE) + { + if (pcc2->marker == NO_MARKER) + { + pcc2->marker = pcc1->marker; + } + else + { + for (k = 0; k < g_cluster_count1; k++) + { + CLUSTER_COORD *pcc3 = g_cluster_ptrs1[k]; + + if (pcc3->marker == pcc2->marker) + pcc3->marker = pcc1->marker; + } + } + } + } + } + + memset(g_super_cluster_coords1, 0, sizeof(g_super_cluster_coords1)); + + g_super_cluster_count1 = 0; + for (i = 1; i <= marker; i++) + { + count = 0; + l = 0x7fff, t = 0x7fff, r = 0, b = 0; + + for (j = 0; j < g_cluster_count1; j++) + { + CLUSTER_COORD *pcc = g_cluster_ptrs1[j]; + + if (pcc->marker == i) + { + if (pcc->rect.left < l) l = pcc->rect.left; + if (pcc->rect.top < t) t = pcc->rect.top; + if (pcc->rect.right > r) r = pcc->rect.right; + if (pcc->rect.bottom > b) b = pcc->rect.bottom; + + count += pcc->count; + } + } + + if (count > 0) + { + printf("marker %d l %d t %d r %d b %d\r\n", i, l, t, r, b); + g_super_cluster_coords1[g_super_cluster_count1].count = count; + g_super_cluster_coords1[g_super_cluster_count1].excluded = __FALSE; + g_super_cluster_coords1[g_super_cluster_count1].marker = NO_MARKER; + g_super_cluster_coords1[g_super_cluster_count1].rect.left = l; + g_super_cluster_coords1[g_super_cluster_count1].rect.top = t; + g_super_cluster_coords1[g_super_cluster_count1].rect.right = r; + g_super_cluster_coords1[g_super_cluster_count1].rect.bottom = b; + g_super_cluster_count1++; + } + + } +} +static void build_clusters_array2(void) +{ + U8 marker; + U16 i, j, k, count; + U16 l, t, r, b; + + cout << "build_clusters_array2" << endl; + + memset(g_cluster_coords2, 0, sizeof(g_cluster_coords2)); + + for (i = 0; i < g_shot_count2; i++) + { + FIFO_ITEM *fi = &g_shot_array2[i]; + U16 x = fi->x / CELL_SIZE; + U16 y = fi->y / CELL_SIZE; + CLUSTER_COORD *pcc = &g_cluster_coords2[y*IMAGE_CELL_CX + x]; + pcc->count++; + pcc->excluded = __FALSE; + pcc->marker = NO_MARKER; + pcc->rect.left = (x)* CELL_SIZE; + pcc->rect.top = (y)* CELL_SIZE; + pcc->rect.right = (x + 1) * CELL_SIZE; + pcc->rect.bottom = (y + 1) * CELL_SIZE; + } + + memset(g_cluster_ptrs2, 0, sizeof(g_cluster_ptrs2)); + + g_cluster_count2 = 0; + for (i = 0; i < IMAGE_CELL_CX*IMAGE_CELL_CY; i++) + { + if (g_cluster_coords2[i].count > 0) + g_cluster_ptrs2[g_cluster_count2++] = &g_cluster_coords2[i]; + } + + marker = NO_MARKER; + for (i = 0; i < g_cluster_count2; i++) + { + CLUSTER_COORD *pcc1 = g_cluster_ptrs2[i]; + S16 x1 = (pcc1->rect.left + pcc1->rect.right) / 2; + S16 y1 = (pcc1->rect.top + pcc1->rect.bottom) / 2; + + if (pcc1->marker == NO_MARKER) + pcc1->marker = (++marker); + + for (j = i + 1; j < g_cluster_count2; j++) + { + CLUSTER_COORD *pcc2 = g_cluster_ptrs2[j]; + S16 x2 = (pcc2->rect.left + pcc2->rect.right) / 2; + S16 y2 = (pcc2->rect.top + pcc2->rect.bottom) / 2; + + if (abs(x1 - x2) == CELL_SIZE && abs(y1 - y2) == CELL_SIZE) + { + if (pcc2->marker == NO_MARKER) + { + pcc2->marker = pcc1->marker; + } + else + { + for (k = 0; k < g_cluster_count2; k++) + { + CLUSTER_COORD *pcc3 = g_cluster_ptrs2[k]; + + if (pcc3->marker == pcc2->marker) + pcc3->marker = pcc1->marker; + } + } + } + } + } + + memset(g_super_cluster_coords2, 0, sizeof(g_super_cluster_coords2)); + + g_super_cluster_count2 = 0; + for (i = 1; i <= marker; i++) + { + count = 0; + l = 0x7fff, t = 0x7fff, r = 0, b = 0; + + for (j = 0; j < g_cluster_count2; j++) + { + CLUSTER_COORD *pcc = g_cluster_ptrs2[j]; + + if (pcc->marker == i) + { + if (pcc->rect.left < l) l = pcc->rect.left; + if (pcc->rect.top < t) t = pcc->rect.top; + if (pcc->rect.right > r) r = pcc->rect.right; + if (pcc->rect.bottom > b) b = pcc->rect.bottom; + + count += pcc->count; + } + } + + if (count > 0) + { + printf("marker %d l %d t %d r %d b %d\r\n", i, l, t, r, b); + g_super_cluster_coords2[g_super_cluster_count2].count = count; + g_super_cluster_coords2[g_super_cluster_count2].excluded = __FALSE; + g_super_cluster_coords2[g_super_cluster_count2].marker = NO_MARKER; + g_super_cluster_coords2[g_super_cluster_count2].rect.left = l; + g_super_cluster_coords2[g_super_cluster_count2].rect.top = t; + g_super_cluster_coords2[g_super_cluster_count2].rect.right = r; + g_super_cluster_coords2[g_super_cluster_count2].rect.bottom = b; + g_super_cluster_count2++; + } + } +} +static void exclude_intersected_clusters_from_array1(void) +{ + U16 i, j; + + for (i = 0; i < g_super_cluster_count1; i++) + { + CLUSTER_COORD *c1 = &g_super_cluster_coords1[i]; + + for (j = 0; j < g_super_cluster_count2; j++) + { + CLUSTER_COORD *c2 = &g_super_cluster_coords2[j]; + + if (IntersectRect(NULL, &c1->rect, &c2->rect)) + c1->excluded = __TRUE; + } + } +} +static void exclude_intersected_clusters_from_array2(void) +{ + U16 i, j; + + for (i = 0; i < g_super_cluster_count2; i++) + { + CLUSTER_COORD *c2 = &g_super_cluster_coords2[i]; + + for (j = 0; j < g_super_cluster_count1; j++) + { + CLUSTER_COORD *c1 = &g_super_cluster_coords1[j]; + + if (IntersectRect(NULL, &c1->rect, &c2->rect)) + c2->excluded = __TRUE; + } + } +} +static void enlarge_clusters_in_array1(void) +{ + U16 i; + + cout << "enlarge_clusters_in_array1" << endl; + + for (i = 0; i < g_super_cluster_count1; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords1[i]; + + if (pcc->rect.left >= CELL_SIZE) pcc->rect.left -= CELL_SIZE; + if (pcc->rect.top >= CELL_SIZE) pcc->rect.top -= CELL_SIZE; + if (pcc->rect.right <= IMAGE_CX - CELL_SIZE) pcc->rect.right += CELL_SIZE; + if (pcc->rect.bottom <= IMAGE_CY - CELL_SIZE) pcc->rect.bottom += CELL_SIZE; + } +} +static void enlarge_clusters_in_array2(void) +{ + U16 i; + cout << "enlarge_clusters_in_array2" << endl; + + for (i = 0; i < g_super_cluster_count2; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords2[i]; + + if (pcc->rect.left >= CELL_SIZE) pcc->rect.left -= CELL_SIZE; + if (pcc->rect.top >= CELL_SIZE) pcc->rect.top -= CELL_SIZE; + if (pcc->rect.right <= IMAGE_CX - CELL_SIZE) pcc->rect.right += CELL_SIZE; + if (pcc->rect.bottom <= IMAGE_CY - CELL_SIZE) pcc->rect.bottom += CELL_SIZE; + } +} +static BIT calculate_mass_centre_by_array1(float *px, float *py) +{ + U16 i, j, c = 0; + float fx = 0, fy = 0; + + for (i = 0; i < g_super_cluster_count1; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords1[i]; + + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count1; j++) + { + U16 x = g_shot_array1[j].x; + U16 y = g_shot_array1[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + } + } + + if (c > 0) + { + *px = fx / (float)c; + *py = fy / (float)c; + + return __TRUE; + } + + return __FALSE; +} +static BIT calculate_mass_centre_by_array2(float *px, float *py) +{ + U16 i, j, c = 0; + float fx = 0, fy = 0; + + for (i = 0; i < g_super_cluster_count2; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords2[i]; + + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count2; j++) + { + U16 x = g_shot_array2[j].x; + U16 y = g_shot_array2[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + } + } + + if (c > 0) + { + *px = fx / (float)c; + *py = fy / (float)c; + + return __TRUE; + } + + return __FALSE; +} +static void calculate_angles(float x, float y, S16 *pAngle1, S16 *pAngle2) +{ + static float A, B, C; + static float Xo, Yo; + static float R, Alpha; + static float sinB, cosB, sinA; + static float Fi = 0, Tetta = 0; + + A = g_config1.fA; + B = g_config1.fB; + C = g_config1.fC; + Xo = (float)g_config1.nXc; + Yo = (float)g_config1.nYc; + + R = sqrt((x - Xo)*(x - Xo) + (y - Yo)*(y - Yo)); + if (R > 0.0) + { + float r = R;// * 122.0 / ((float)g_config1.nRs - 10.0); // default: (Rs - 10.0) + + Alpha = (A*r*r*r + B*r*r + C*r) * M_PI / 180.0; + if (Alpha > 90.0 * M_PI / 180.0) Alpha = 90.0 * M_PI / 180.0; + if (Alpha < 0.0) Alpha = 0.0; + + sinB = (y - Yo) / R; + cosB = (x - Xo) / R; + sinA = sin(Alpha); + + Tetta = asin(sinA * sinB); // Tetta: -PI/2...+PI/2 + + if (fabs(Tetta) >= M_PI / 2.0) Fi = 0.0; + else Fi = asin(sinA * cosB / cos(Tetta)); // Fi: -PI/2...+PI/2 + } + + *pAngle1 = (S16)rint((-Fi * 180.0 / M_PI) * 60.0); + *pAngle2 = (S16)rint((-Tetta * 180.0 / M_PI) * 60.0); +} +static BIT calculate_mass_centre(FIFO_ITEM_f *mass, U16 *num, U8 array) +{ + U16 i, j, c = 0; + float fx = 0, fy = 0; + + if (array == 1) + { + for (i = 0; i < g_super_cluster_count1; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords1[i]; + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count1; j++) + { + U16 x = g_shot_array1[j].x; + U16 y = g_shot_array1[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + *num = *num + 1; + } + if (*num > 0 && c > 0) + { + mass[*num - 1].x = fx / (float)c; + mass[*num - 1].y = fy / (float)c; + c = 0; + fx = 0; + fy = 0; + printf("cnt = %d x = %6.2f y = %6.2f\r\n", *num - 1, mass[*num - 1].x, mass[*num - 1].y); + } + } + } + else + { + for (i = 0; i < g_super_cluster_count2; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords2[i]; + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count2; j++) + { + U16 x = g_shot_array2[j].x; + U16 y = g_shot_array2[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + *num = *num + 1; + } + if (*num > 0 && c > 0) + { + mass[*num - 1].x = fx / (float)c; + mass[*num - 1].y = fy / (float)c; + c = 0; + fx = 0; + fy = 0; + printf("cnt = %d x = %6.2f y = %6.2f\r\n", *num - 1, mass[*num - 1].x, mass[*num - 1].y); + } + } + } + if (*num > 0) + { + return __TRUE; + } + return __FALSE; +} +static BIT cmcentre(U8 array) +{ + U16 i, j, c = 0, cc = 0; + float fx = 0, fy = 0; + S16 angle1, angle2; + COORDS_DATA coords; + + if (array == 1) + { + for (i = 0; i < g_super_cluster_count1; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords1[i]; + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count1; j++) + { + U16 x = g_shot_array1[j].x; + U16 y = g_shot_array1[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + cc = cc + 1; + } + if (cc > 0 && c > 0) + { + S16 _x = fx / (float)c; + S16 _y = fy / (float)c; + calculate_angles(_x, _y, &angle1, &angle2); + coords.time = (U32)get_time_10us(); + coords.angle1 = angle1; + coords.angle2 = angle2; + push_coords_item(&coords); + c = 0; + fx = 0; + fy = 0; + printf("cnt=%d x=%d y=%d az=%d*%d' um=%d*%d'\r\n", cc - 1, _x, _y, angle1 / 60, abs(angle1 % 60), angle2 / 60, abs(angle2 % 60)); + } + } + } + else + { + for (i = 0; i < g_super_cluster_count2; i++) + { + CLUSTER_COORD *pcc = &g_super_cluster_coords2[i]; + if (pcc->excluded == __FALSE) + { + for (j = 0; j < g_shot_count2; j++) + { + U16 x = g_shot_array2[j].x; + U16 y = g_shot_array2[j].y; + + if (x >= pcc->rect.left && x < pcc->rect.right && + y >= pcc->rect.top && y < pcc->rect.bottom) + { + fx += x; + fy += y; + c++; + } + } + cc = cc + 1; + } + if (cc > 0 && c > 0) + { + S16 _x = fx / (float)c; + S16 _y = fy / (float)c; + calculate_angles(_x, _y, &angle1, &angle2); + coords.time = (U32)get_time_10us(); + coords.angle1 = angle1; + coords.angle2 = angle2; + push_coords_item(&coords); + c = 0; + fx = 0; + fy = 0; + printf("cnt=%d x=%d y=%d az=%d*%d' um=%d*%d'\r\n", cc - 1, _x, _y, angle1 / 60, abs(angle1 % 60), angle2 / 60, abs(angle2 % 60)); + } + } + } + if (cc > 0) + { + return __TRUE; + } + return __FALSE; +} + +BIT push_coords_item(const COORDS_DATA *coords) +{ + // FIFO buffer is full? exit + if (g_coords_index == COORDS_FIFO_SIZE) + { + return __FALSE; + } + g_coords[g_coords_index++] = *coords; + return __TRUE; +} +BIT pop_coords_item(COORDS_DATA *coords) +{ + // FIFO buffer is empty? exit + if (g_coords_index == 0) + { + return __FALSE; + } + *coords = g_coords[--g_coords_index]; + return __TRUE; +} +U16 get_coords_count(void) +{ + U16 count; + count = g_coords_index; + return count; +} +static U64 get_time_10us(void) +{ + U64 init_time_10us; + init_time_10us = g_init_time_10us; +// return init_time_10us + rtc_GetTickCount_us() / 10; + return init_time_10us + 0; // rtc_GetTickCount_us() / 10; +} + +void ssaimage(_TCHAR *fname, int num) +{ + CImage ci; + ci.Load(fname); + CString fn = fname; + USES_CONVERSION; + + if (num == 1) + { + for (int i = 0; i < g_shot_count1; i++) + { + ci.SetPixel(g_shot_array1[i].x, g_shot_array1[i].y, RGB(255, 0, 0)); + } + drawcircle(&ci, 160, 128, g_config1.nRb + 1, RGB(255, 0, 255)); + drawcircle(&ci, g_config1.nXc, g_config1.nYc, g_config1.nRb + 1, RGB(255, 128, 255)); + } + else + { + for (int i = 0; i < g_shot_count2; i++) + { + ci.SetPixel(g_shot_array2[i].x, g_shot_array2[i].y, RGB(255, 0, 0)); + } + drawcircle(&ci, 160, 128, g_config2.nRb + 1, RGB(255, 0, 255)); + drawcircle(&ci, g_config2.nXc, g_config2.nYc, g_config2.nRb + 1, RGB(255, 128, 255)); + } + fn.Delete(0, 1); + fn = _T("1") + fn; + ci.Save(fn); + ci.Destroy(); +} +void bcaimage(_TCHAR *fname, int num) +{ + CImage ci; + USES_CONVERSION; + CString fn = fname; + fn.Delete(0, 1); + fn = _T("1") + fn; + ci.Load(fn); + if (num == 1) + { + for (int i = 0; i < g_super_cluster_count1; i++) + { + drawrect(&ci, + g_super_cluster_coords1[i].rect.left, + g_super_cluster_coords1[i].rect.top, + g_super_cluster_coords1[i].rect.right, + g_super_cluster_coords1[i].rect.bottom, + RGB(0, 255, 0)); + } + } + else + { + for (int i = 0; i < g_super_cluster_count2; i++) + { + drawrect(&ci, + g_super_cluster_coords2[i].rect.left, + g_super_cluster_coords2[i].rect.top, + g_super_cluster_coords2[i].rect.right, + g_super_cluster_coords2[i].rect.bottom, + RGB(0, 255, 0)); + } + } + fn.Delete(0, 1); + fn = _T("2") + fn; + ci.Save(fn); + ci.Destroy(); +} +void bcaimage2(_TCHAR *fname, int num) +{ + CImage ci; + USES_CONVERSION; + CString fn = fname; + fn.Delete(0, 1); + fn = _T("2") + fn; + ci.Load(fn); + if (num == 1) + { + for (int i = 0; i < g_super_cluster_count1; i++) + { + drawrect(&ci, + g_super_cluster_coords1[i].rect.left, + g_super_cluster_coords1[i].rect.top, + g_super_cluster_coords1[i].rect.right, + g_super_cluster_coords1[i].rect.bottom, + RGB(0, 128, 255)); + } + } + else + { + for (int i = 0; i < g_super_cluster_count2; i++) + { + drawrect(&ci, + g_super_cluster_coords2[i].rect.left, + g_super_cluster_coords2[i].rect.top, + g_super_cluster_coords2[i].rect.right, + g_super_cluster_coords2[i].rect.bottom, + RGB(0, 128, 255)); + } + } + fn.Delete(0, 1); + fn = _T("3") + fn; + ci.Save(fn); + ci.Destroy(); +} +void eicimage(_TCHAR *fname, int num) +{ + CImage ci; + USES_CONVERSION; + CString fn = fname; + fn.Delete(0, 1); + fn = _T("1") + fn; + ci.Load(fn); + if (num == 1) + { + for (int i = 0; i < g_super_cluster_count1; i++) + { + if (g_super_cluster_coords1[i].excluded == __TRUE) + { + drawrectsolid(&ci, + g_super_cluster_coords1[i].rect.left, + g_super_cluster_coords1[i].rect.top, + g_super_cluster_coords1[i].rect.right, + g_super_cluster_coords1[i].rect.bottom, + RGB(0, 0, 0)); + } + else + { + drawrect(&ci, + g_super_cluster_coords1[i].rect.left, + g_super_cluster_coords1[i].rect.top, + g_super_cluster_coords1[i].rect.right, + g_super_cluster_coords1[i].rect.bottom, + RGB(0, 255, 0)); + } + } + drawcircle(&ci, 160, 128, g_config1.nRb + 1, RGB(255, 0, 255)); + drawcircle(&ci, g_config1.nXc, g_config1.nYc, g_config1.nRb + 1, RGB(255, 128, 255)); + } + else + { + for (int i = 0; i < g_super_cluster_count2; i++) + { + if (g_super_cluster_coords1[i].excluded == __TRUE) + { + drawrectsolid(&ci, + g_super_cluster_coords2[i].rect.left, + g_super_cluster_coords2[i].rect.top, + g_super_cluster_coords2[i].rect.right, + g_super_cluster_coords2[i].rect.bottom, + RGB(0, 0, 0)); + } + else + { + drawrect(&ci, + g_super_cluster_coords2[i].rect.left, + g_super_cluster_coords2[i].rect.top, + g_super_cluster_coords2[i].rect.right, + g_super_cluster_coords2[i].rect.bottom, + RGB(0, 255, 0)); + } + } + drawcircle(&ci, 160, 128, g_config2.nRb + 1, RGB(255, 0, 255)); + drawcircle(&ci, g_config2.nXc, g_config2.nYc, g_config2.nRb + 1, RGB(255, 128, 255)); + } + fn.Delete(0, 1); + fn = _T("4") + fn; + ci.Save(fn); + ci.Destroy(); + ci.Destroy(); +} +void cmcimage(_TCHAR *fname, int num, U16 x, U16 y) +{ + CImage ci; + USES_CONVERSION; + CString fn = fname; + fn.Delete(0, 1); + fn = _T("4") + fn; + ci.Load(fn); + if (num == 1) + { + for (int i = x - 10; i <= x + 10; i++) + { + ci.SetPixel(i, y, RGB(0, 206, 209)); + } + for (int i = y - 10; i <= y + 10; i++) + { + ci.SetPixel(x, i, RGB(0, 206, 209)); + } + } + else + { + for (int i = x - 10; i <= x + 10; i++) + { + ci.SetPixel(i, y, RGB(0, 206, 209)); + } + for (int i = y - 10; i <= y + 10; i++) + { + ci.SetPixel(x, i, RGB(0, 206, 209)); + } + } + fn.Delete(0, 1); + fn = _T("5") + fn; + ci.Save(fn); + ci.Destroy(); + ci.Destroy(); +} +void cmcimage2(_TCHAR *fname, FIFO_ITEM_f *centr, U16 num, U8 array) +{ + CImage ci; + USES_CONVERSION; + CString fn = fname; + fn.Delete(0, 1); + fn = _T("5") + fn; + ci.Load(fn); + for (int j = 0; j < num; j++) + { + if (array == 1) + { + for (int i = centr[j].x - 10; i <= centr[j].x + 10; i++) + { + ci.SetPixel(i, centr[j].y, RGB(255, 255, 0)); + } + for (int i = centr[j].y - 10; i <= centr[j].y + 10; i++) + { + ci.SetPixel(centr[j].x, i, RGB(255, 255, 0)); + } + } + else + { + for (int i = centr[j].x - 10; i <= centr[j].x + 10; i++) + { + ci.SetPixel(i, centr[j].y, RGB(255, 255, 0)); + } + for (int i = centr[j].y - 10; i <= centr[j].y + 10; i++) + { + ci.SetPixel(centr[j].x, i, RGB(255, 255, 0)); + } + } + } + fn.Delete(0, 1); + fn = _T("6") + fn; + ci.Save(fn); + ci.Destroy(); + ci.Destroy(); +} +void drawrect(CImage *im, U16 l, U16 t, U16 r, U16 b, COLORREF color) +{ + for (int i = l; i <= r; i++) + { + im->SetPixel(i, t, color); + im->SetPixel(i, b, color); + } + for (int i = t; i <= b; i++) + { + im->SetPixel(l, i, color); + im->SetPixel(r, i, color); + } +} +void drawcircle(CImage *im, U16 x, U16 y, U16 r, COLORREF color) +{ + U16 cx = 0; + U16 cy = 0; + double xLimit = sqrt((double)(r * r) / 2); + + while (cx++ <= xLimit) + { + cy = (LONG)floor(sqrt(r * r - cx * cx)); + im->SetPixel(cx + x, cy + y, color); // 45-90 degrees + im->SetPixel(cx + x, -cy + y, color); // 270-315 degrees + im->SetPixel(-cx + x, cy + y, color); // 90-135 degrees + im->SetPixel(-cx + x, -cy + y, color); // 225-270 degrees + im->SetPixel(cy + x, cx + y, color); // 0-45 degrees + im->SetPixel(cy + x, -cx + y, color); // 315-360 degrees + im->SetPixel(-cy + x, cx + y, color); // 135-180 degrees + im->SetPixel(-cy + x, -cx + y, color); // 180-225 degrees + } +} +void drawrectsolid(CImage *im, U16 l, U16 t, U16 r, U16 b, COLORREF color) +{ + for (int i = l; i <= r; i++) + { + for (int j = t; j <= b; j++) + im->SetPixel(i, j, color); + } +} + diff --git a/ConsoleApplication1/ConsoleApplication1.vcxproj b/ConsoleApplication1/ConsoleApplication1.vcxproj new file mode 100644 index 0000000..5993696 --- /dev/null +++ b/ConsoleApplication1/ConsoleApplication1.vcxproj @@ -0,0 +1,99 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {F7F6C86C-4770-450C-A162-194389C17D2D} + Win32Proj + ConsoleApplication1 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + true + .\Debug + + + false + .\Release + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + stdcpp17 + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + stdcpp17 + + + Console + true + true + true + + + + + + + + + + + + + + Create + Create + + + + + + \ No newline at end of file diff --git a/ConsoleApplication1/ConsoleApplication1.vcxproj.filters b/ConsoleApplication1/ConsoleApplication1.vcxproj.filters new file mode 100644 index 0000000..a832560 --- /dev/null +++ b/ConsoleApplication1/ConsoleApplication1.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Заголовочные файлы + + + Заголовочные файлы + + + Заголовочные файлы + + + + + Файлы исходного кода + + + Файлы исходного кода + + + \ No newline at end of file diff --git a/ConsoleApplication1/ConsoleApplication1.vcxproj.user b/ConsoleApplication1/ConsoleApplication1.vcxproj.user new file mode 100644 index 0000000..47b819d --- /dev/null +++ b/ConsoleApplication1/ConsoleApplication1.vcxproj.user @@ -0,0 +1,7 @@ + + + + 111.bmp 222.bmp + WindowsLocalDebugger + + \ No newline at end of file diff --git a/ConsoleApplication1/main.h b/ConsoleApplication1/main.h new file mode 100644 index 0000000..dd8ba51 --- /dev/null +++ b/ConsoleApplication1/main.h @@ -0,0 +1,174 @@ +#ifndef MAIN_H_INCLUDED +#define MAIN_H_INCLUDED + +typedef unsigned char U8; +typedef signed char S8; +typedef unsigned short U16; +typedef signed short S16; +typedef unsigned int U32; +typedef signed int S32; +typedef unsigned long long U64; +typedef signed long long S64; +typedef bool BIT; + +#define __FALSE 0 +#define __TRUE 1 + +#define BAD_PIXELS_ARRAY_SIZE 256 +#define NO_MARKER 0 // 'no marker' cluster identifier +#define SN_LENGTH 128 +// FIFO coordinate XY-correction +#define FIFO_X_OFFSET -11 +#define FIFO_Y_OFFSET -4 +//--------------------------------------------------------------------------- +// CMOS matrix definitions +#define IMAGE_CX (320-1) +#define IMAGE_CY (256-1) +#define CELL_SIZE 8 // cluster cell size, in pix +#define IMAGE_CELL_CX ((IMAGE_CX + CELL_SIZE - 1) / CELL_SIZE) +#define IMAGE_CELL_CY ((IMAGE_CY + CELL_SIZE - 1) / CELL_SIZE) + + +typedef struct +{ + U16 bfType; + U32 bfSize; + U16 bfReserved1; + U16 bfReserved2; + U32 bfOffBits; +} BFHEADER; + +typedef struct +{ + U32 biSize; + S32 biWidth; + S32 biHeight; + U16 biPlanes; + U16 biBitCount; + U32 biCompression; + U32 biSizeImage; + S32 biXPelsPerMeter; + S32 biYPelsPerMeter; + U32 biClrUsed; + U32 biClrImportant; +} BIHEADER; + + +typedef struct +{ + U8 rgbBlue; + U8 rgbGreen; + U8 rgbRed; + U8 rgbReserved; +} RGBQ; + +typedef struct +{ + float x; + float y; +} FIFO_ITEM_f; + +static unsigned short read_u16(FILE *fp); +static unsigned int read_u32(FILE *fp); +static int read_s32(FILE *fp); + + +#pragma pack(push, 1) +typedef struct +{ + unsigned short left; + unsigned short top; + unsigned short right; + unsigned short bottom; + +} ARM_RECT; + +typedef struct +{ + U16 x; + U16 y; +} FIFO_ITEM; + +typedef struct +{ + U16 count; + FIFO_ITEM array[BAD_PIXELS_ARRAY_SIZE]; +} BAD_PIX_FILE_STRUCTURE; + +typedef struct +{ + FIFO_ITEM *pi; + U8 *pm; +} THE_POINT; + +typedef struct +{ + U16 count; // number of points (pixels) in cluster + U8 excluded; // flag, cluster should be ignored if TRUE + U8 marker; // cluster identicator + ARM_RECT rect; // rectangular area of cluster (in pixels) +} CLUSTER_COORD; + +typedef struct +{ + U32 time; // time of alarm, in 10us units + S16 angle1; // + S16 angle2; // +} COORDS_DATA; + +typedef struct +{ + U8 szSerialNumber[SN_LENGTH];// matrix serial number, zero-terminated string + U16 nXc, nYc; // centers of matrices, pix + U16 nRs, nRb; // lens field of view radius ('s'=small, 'b'=big), pix + U8 cLc; // neighbour distance for clasters, pix + U16 nLimit; // FIFO limit (10-bit) + U16 nVinb, nVref; // VINB & VREF (10-bit) + float fA, fB, fC; // Fi=A*x^2 + Bx + C +} CONFIG_FILE_STRUCTURE; + +#pragma pack(pop) + + +#define COORDS_FIFO_SIZE 16 // maximum number of items in coordinates FIFO array +//---------------------------------------------------------------------------- +#define ENTER_CRITICAL_SECTION() os_mut_wait(g_mutex, 0xffff) +#define LEAVE_CRITICAL_SECTION() os_mut_release(g_mutex) +//---------------------------------------------------------------------------- +// constant variables +static const char g_badpix_filename1[] = "S:\\bad_pix1.raw"; +static const char g_badpix_filename2[] = "S:\\bad_pix2.raw"; +static const char g_config_filename1[] = "S:\\config1.raw"; +static const char g_config_filename2[] = "S:\\config2.raw"; +//---------------------------------------------------------------------------- +// common inter-task variables (access-protected by mutex) +static U64 g_init_time_10us; +static COORDS_DATA g_coords[COORDS_FIFO_SIZE]; // coordinates FIFO array +static U16 g_coords_index = 0; // index of 1-st free item in array +//---------------------------------------------------------------------------- +// transmittion task CAN id +//---------------------------------------------------------------------------- +// bad pixels & config variables +static BAD_PIX_FILE_STRUCTURE g_bad_pixels1; // bad pixel array for CMOS1 +static BAD_PIX_FILE_STRUCTURE g_bad_pixels2; // bad pixel array for CMOS2 +static CONFIG_FILE_STRUCTURE g_config1; // config settings for CMOS1 +static CONFIG_FILE_STRUCTURE g_config2; // config settings for CMOS2 +// shot fifo & cluster variables +static FIFO_ITEM g_shot_array1[4096]; // shot XY-coordinates from FIFO1 +static FIFO_ITEM g_shot_array2[4096]; // shot XY-coordinates from FIFO2 +static U16 g_shot_count1; // number of shot XY-coordinate pairs in FIFO1 +static U16 g_shot_count2; // number of shot XY-coordinate pairs in FIFO2 +static CLUSTER_COORD g_cluster_coords1[IMAGE_CELL_CX*IMAGE_CELL_CY]; // clusters mass centre & coordinates in FIFO1 +static CLUSTER_COORD g_cluster_coords2[IMAGE_CELL_CX*IMAGE_CELL_CY]; // clusters mass centre & coordinates in FIFO2 +static CLUSTER_COORD *g_cluster_ptrs1[IMAGE_CELL_CX*IMAGE_CELL_CY]; // +static CLUSTER_COORD *g_cluster_ptrs2[IMAGE_CELL_CX*IMAGE_CELL_CY]; // +static U16 g_cluster_count1; // number of clusters (8x8) in FIFO1 +static U16 g_cluster_count2; // number of clusters (8x8) in FIFO2 +static CLUSTER_COORD g_super_cluster_coords1[IMAGE_CELL_CX*IMAGE_CELL_CY]; +static CLUSTER_COORD g_super_cluster_coords2[IMAGE_CELL_CX*IMAGE_CELL_CY]; +static U16 g_super_cluster_count1; // number of super clusters in FIFO1 +static U16 g_super_cluster_count2; // number of super clusters in FIFO2 + + + +#endif // MAIN_H_INCLUDEDs \ No newline at end of file diff --git a/ConsoleApplication1/stdafx.cpp b/ConsoleApplication1/stdafx.cpp new file mode 100644 index 0000000..a25358f --- /dev/null +++ b/ConsoleApplication1/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp: , +// ConsoleApplication1.pch +// stdafx.obj + +#include "stdafx.h" + +// TODO: STDAFX.H +// , diff --git a/ConsoleApplication1/stdafx.h b/ConsoleApplication1/stdafx.h new file mode 100644 index 0000000..0f9f6c9 --- /dev/null +++ b/ConsoleApplication1/stdafx.h @@ -0,0 +1,19 @@ +// stdafx.h: +// , , +// +// + +#pragma once + +#include "targetver.h" + +#include +#include + + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // CString + +#include +#include + +// TODO: , diff --git a/ConsoleApplication1/targetver.h b/ConsoleApplication1/targetver.h new file mode 100644 index 0000000..fd33074 --- /dev/null +++ b/ConsoleApplication1/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h Windows. + +// Windows, WinSDKVer.h +// _WIN32_WINNT SDKDDKVer.h. + +#include diff --git a/Test_img.sln b/Test_img.sln new file mode 100644 index 0000000..4f4af98 --- /dev/null +++ b/Test_img.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_img", "Test_img\Test_img.csproj", "{AE96C475-3F2E-409C-9213-A049FB9CAD10}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "C:\Work\C++\Test_img\ConsoleApplication1\ConsoleApplication1.vcxproj", "{F7F6C86C-4770-450C-A162-194389C17D2D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Debug|x86.ActiveCfg = Debug|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Debug|x86.Build.0 = Debug|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Release|Any CPU.Build.0 = Release|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Release|x86.ActiveCfg = Release|Any CPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10}.Release|x86.Build.0 = Release|Any CPU + {F7F6C86C-4770-450C-A162-194389C17D2D}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Debug|Any CPU.Build.0 = Debug|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Debug|x86.ActiveCfg = Debug|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Debug|x86.Build.0 = Debug|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Release|Any CPU.ActiveCfg = Release|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Release|Any CPU.Build.0 = Release|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Release|x86.ActiveCfg = Release|Win32 + {F7F6C86C-4770-450C-A162-194389C17D2D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EE63C273-8D09-484A-9870-582C052D7575} + EndGlobalSection +EndGlobal diff --git a/Test_img/App.config b/Test_img/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/Test_img/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Test_img/Form1.Designer.cs b/Test_img/Form1.Designer.cs new file mode 100644 index 0000000..466f986 --- /dev/null +++ b/Test_img/Form1.Designer.cs @@ -0,0 +1,416 @@ +namespace Test_img +{ + partial class Form1 + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.img_resolution = new System.Windows.Forms.ToolStripStatusLabel(); + this.img_aspect = new System.Windows.Forms.ToolStripStatusLabel(); + this.img_coord = new System.Windows.Forms.ToolStripStatusLabel(); + this.img_color = new System.Windows.Forms.ToolStripStatusLabel(); + this.img_srch = new System.Windows.Forms.ToolStripStatusLabel(); + this.ttt = new System.Windows.Forms.ToolStripStatusLabel(); + this.yyy = new System.Windows.Forms.ToolStripStatusLabel(); + this.menu = new System.Windows.Forms.MenuStrip(); + this.MenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.img_load = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator(); + this.exit = new System.Windows.Forms.ToolStripMenuItem(); + this.MenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.развернутьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.свернутьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.MenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); + this.img1 = new System.Windows.Forms.ToolStripMenuItem(); + this.img2 = new System.Windows.Forms.ToolStripMenuItem(); + this.img3 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.img_timer = new System.Windows.Forms.ToolStripMenuItem(); + this.img_smooth = new System.Windows.Forms.ToolStripMenuItem(); + this.img_center = new System.Windows.Forms.ToolStripMenuItem(); + this.minus_fon = new System.Windows.Forms.ToolStripMenuItem(); + this.img_search = new System.Windows.Forms.ToolStripMenuItem(); + this.img_fon = new System.Windows.Forms.ToolStripMenuItem(); + this.img_save = new System.Windows.Forms.ToolStripMenuItem(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.statusStrip1.SuspendLayout(); + this.menu.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.img_resolution, + this.img_aspect, + this.img_coord, + this.img_color, + this.img_srch, + this.ttt, + this.yyy}); + this.statusStrip1.Location = new System.Drawing.Point(0, 543); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(650, 24); + this.statusStrip1.TabIndex = 1; + this.statusStrip1.Text = "statusStrip1"; + // + // img_resolution + // + this.img_resolution.AutoSize = false; + this.img_resolution.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.img_resolution.Name = "img_resolution"; + this.img_resolution.Size = new System.Drawing.Size(70, 19); + this.img_resolution.Text = "4000 X 3000"; + // + // img_aspect + // + this.img_aspect.AutoSize = false; + this.img_aspect.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; + this.img_aspect.Name = "img_aspect"; + this.img_aspect.Size = new System.Drawing.Size(90, 19); + this.img_aspect.Text = "Аспект 12.999"; + // + // img_coord + // + this.img_coord.AutoSize = false; + this.img_coord.Name = "img_coord"; + this.img_coord.Size = new System.Drawing.Size(105, 19); + this.img_coord.Text = "X = 0000 Y = 0000"; + // + // img_color + // + this.img_color.AutoSize = false; + this.img_color.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.img_color.Name = "img_color"; + this.img_color.Size = new System.Drawing.Size(110, 19); + this.img_color.Text = "R:000 G:000 B:000"; + // + // img_srch + // + this.img_srch.AutoSize = false; + this.img_srch.Name = "img_srch"; + this.img_srch.Size = new System.Drawing.Size(55, 19); + this.img_srch.Text = "Фон: 000"; + // + // ttt + // + this.ttt.AutoSize = false; + this.ttt.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; + this.ttt.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.ttt.Name = "ttt"; + this.ttt.Size = new System.Drawing.Size(70, 19); + this.ttt.Text = "-0000 -0000"; + // + // yyy + // + this.yyy.AutoSize = false; + this.yyy.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; + this.yyy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.yyy.Name = "yyy"; + this.yyy.Size = new System.Drawing.Size(70, 19); + this.yyy.Text = "0000 0000"; + // + // menu + // + this.menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.MenuItem1, + this.MenuItem2, + this.MenuItem3}); + this.menu.Location = new System.Drawing.Point(0, 0); + this.menu.Name = "menu"; + this.menu.Size = new System.Drawing.Size(650, 24); + this.menu.TabIndex = 7; + this.menu.Text = "menuStrip1"; + // + // MenuItem1 + // + this.MenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.img_load, + this.toolStripMenuItem2, + this.toolStripMenuItem7, + this.exit}); + this.MenuItem1.Name = "MenuItem1"; + this.MenuItem1.Size = new System.Drawing.Size(48, 20); + this.MenuItem1.Text = "Файл"; + // + // img_load + // + this.img_load.Name = "img_load"; + this.img_load.Size = new System.Drawing.Size(210, 22); + this.img_load.Text = "Загрузить изображение"; + this.img_load.Click += new System.EventHandler(this.img_load_Click); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(210, 22); + this.toolStripMenuItem2.Text = "Сохранить изображение"; + this.toolStripMenuItem2.Click += new System.EventHandler(this.img_save_Click); + // + // toolStripMenuItem7 + // + this.toolStripMenuItem7.Name = "toolStripMenuItem7"; + this.toolStripMenuItem7.Size = new System.Drawing.Size(207, 6); + // + // exit + // + this.exit.Name = "exit"; + this.exit.Size = new System.Drawing.Size(210, 22); + this.exit.Text = "Выход"; + this.exit.Click += new System.EventHandler(this.exit_Click); + // + // MenuItem2 + // + this.MenuItem2.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.развернутьToolStripMenuItem, + this.свернутьToolStripMenuItem}); + this.MenuItem2.Name = "MenuItem2"; + this.MenuItem2.Size = new System.Drawing.Size(39, 20); + this.MenuItem2.Text = "Вид"; + // + // развернутьToolStripMenuItem + // + this.развернутьToolStripMenuItem.Name = "развернутьToolStripMenuItem"; + this.развернутьToolStripMenuItem.Size = new System.Drawing.Size(135, 22); + this.развернутьToolStripMenuItem.Text = "Развернуть"; + this.развернутьToolStripMenuItem.Click += new System.EventHandler(this.развернутьToolStripMenuItem_Click); + // + // свернутьToolStripMenuItem + // + this.свернутьToolStripMenuItem.Name = "свернутьToolStripMenuItem"; + this.свернутьToolStripMenuItem.Size = new System.Drawing.Size(135, 22); + this.свернутьToolStripMenuItem.Text = "Свернуть"; + this.свернутьToolStripMenuItem.Click += new System.EventHandler(this.свернутьToolStripMenuItem_Click); + // + // MenuItem3 + // + this.MenuItem3.AutoSize = false; + this.MenuItem3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem5, + this.img_smooth, + this.img_center, + this.img_search, + this.img_fon, + this.img_save}); + this.MenuItem3.Name = "MenuItem3"; + this.MenuItem3.Size = new System.Drawing.Size(122, 20); + this.MenuItem3.Text = "Инструменты"; + // + // toolStripMenuItem5 + // + this.toolStripMenuItem5.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.img1, + this.img2, + this.img3, + this.toolStripSeparator1, + this.img_timer}); + this.toolStripMenuItem5.Name = "toolStripMenuItem5"; + this.toolStripMenuItem5.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem5.Text = "Демо-картинка"; + // + // img1 + // + this.img1.Name = "img1"; + this.img1.Size = new System.Drawing.Size(104, 22); + this.img1.Text = "1"; + this.img1.Click += new System.EventHandler(this.img1_Click); + // + // img2 + // + this.img2.Name = "img2"; + this.img2.Size = new System.Drawing.Size(104, 22); + this.img2.Text = "2"; + this.img2.Click += new System.EventHandler(this.img2_Click); + // + // img3 + // + this.img3.Name = "img3"; + this.img3.Size = new System.Drawing.Size(104, 22); + this.img3.Text = "3"; + this.img3.Click += new System.EventHandler(this.img3_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(101, 6); + // + // img_timer + // + this.img_timer.Checked = true; + this.img_timer.CheckOnClick = true; + this.img_timer.CheckState = System.Windows.Forms.CheckState.Checked; + this.img_timer.Image = global::Test_img.Properties.Resources.CheckBoxChecked; + this.img_timer.Name = "img_timer"; + this.img_timer.Size = new System.Drawing.Size(104, 22); + this.img_timer.Text = "Timer"; + this.img_timer.Click += new System.EventHandler(this.img_timer_Click); + // + // img_smooth + // + this.img_smooth.CheckOnClick = true; + this.img_smooth.Image = global::Test_img.Properties.Resources.CheckBoxUnchecked; + this.img_smooth.Name = "img_smooth"; + this.img_smooth.Size = new System.Drawing.Size(180, 22); + this.img_smooth.Text = "Размытие"; + this.img_smooth.Click += new System.EventHandler(this.img_smooth_Click); + // + // img_center + // + this.img_center.CheckOnClick = true; + this.img_center.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.minus_fon}); + this.img_center.Image = global::Test_img.Properties.Resources.CheckBoxUnchecked; + this.img_center.Name = "img_center"; + this.img_center.Size = new System.Drawing.Size(180, 22); + this.img_center.Text = "Центр масс"; + this.img_center.Click += new System.EventHandler(this.img_center_Click); + // + // minus_fon + // + this.minus_fon.CheckOnClick = true; + this.minus_fon.Image = global::Test_img.Properties.Resources.CheckBoxUnchecked; + this.minus_fon.Name = "minus_fon"; + this.minus_fon.Size = new System.Drawing.Size(180, 22); + this.minus_fon.Text = "Вычитать фон"; + this.minus_fon.Click += new System.EventHandler(this.minus_fon_Click); + // + // img_search + // + this.img_search.CheckOnClick = true; + this.img_search.Image = global::Test_img.Properties.Resources.CheckBoxUnchecked; + this.img_search.Name = "img_search"; + this.img_search.Size = new System.Drawing.Size(180, 22); + this.img_search.Text = "Поиск пятна"; + this.img_search.Click += new System.EventHandler(this.img_search_Click); + // + // img_fon + // + this.img_fon.Name = "img_fon"; + this.img_fon.Size = new System.Drawing.Size(180, 22); + this.img_fon.Text = "Фон"; + this.img_fon.Click += new System.EventHandler(this.img_fon_Click); + // + // img_save + // + this.img_save.Name = "img_save"; + this.img_save.Size = new System.Drawing.Size(180, 22); + this.img_save.Text = "Скриншот"; + this.img_save.Click += new System.EventHandler(this.screenshot_Click); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.Location = new System.Drawing.Point(5, 27); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(640, 512); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); + this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); + this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter); + this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); + this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); + this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.ClientSize = new System.Drawing.Size(650, 567); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.menu); + this.Controls.Add(this.pictureBox1); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MainMenuStrip = this.menu; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(666, 606); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.menu.ResumeLayout(false); + this.menu.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.MenuStrip menu; + private System.Windows.Forms.ToolStripMenuItem MenuItem1; + private System.Windows.Forms.ToolStripMenuItem img_load; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem exit; + private System.Windows.Forms.ToolStripMenuItem MenuItem2; + private System.Windows.Forms.ToolStripMenuItem MenuItem3; + private System.Windows.Forms.ToolStripMenuItem развернутьToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem свернутьToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; + private System.Windows.Forms.ToolStripMenuItem img_center; + private System.Windows.Forms.ToolStripStatusLabel img_resolution; + private System.Windows.Forms.ToolStripStatusLabel img_aspect; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7; + private System.Windows.Forms.ToolStripStatusLabel img_coord; + private System.Windows.Forms.ToolStripStatusLabel img_color; + private System.Windows.Forms.ToolStripMenuItem img_search; + private System.Windows.Forms.ToolStripStatusLabel img_srch; + private System.Windows.Forms.ToolStripMenuItem img_save; + private System.Windows.Forms.ToolStripStatusLabel ttt; + private System.Windows.Forms.ToolStripStatusLabel yyy; + private System.Windows.Forms.ToolStripMenuItem img1; + private System.Windows.Forms.ToolStripMenuItem img2; + private System.Windows.Forms.ToolStripMenuItem img3; + private System.Windows.Forms.ToolStripMenuItem img_fon; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem img_timer; + private System.Windows.Forms.ToolStripMenuItem img_smooth; + private System.Windows.Forms.ToolStripMenuItem minus_fon; + } +} + diff --git a/Test_img/Form1.cs b/Test_img/Form1.cs new file mode 100644 index 0000000..60f0322 --- /dev/null +++ b/Test_img/Form1.cs @@ -0,0 +1,567 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Reflection; +using System.Windows.Forms; +using UTIL; + +namespace Test_img +{ + public partial class Form1 : Form + { + Bitmap bm = null; + Bitmap newbm = null; + //int ter1 = 0; + //int ter2 = 0; + //int wMax = 0; + //int hMax = 0; + //int wMaxF = 0; + //int hMaxF = 0; + //int panelR = 117; + //int panelD = 84; + int xPos; + int yPos; + + float zoomFactor = 1; + Size resolution = new Size(0, 0); + Size minform = new Size(666, 606); + private Point startingPoint = Point.Empty; + private Point movingPoint = Point.Empty; + private bool panning = false; + private bool select = false; + private Point startSelPoint = Point.Empty; + private Point stopSelPoint = Point.Empty; + private Point SelPoint1 = Point.Empty; + private Point SelPoint2 = Point.Empty; + private Point MassCenter = Point.Empty; + search srch = new search(); + int imgsearch = 200; + UInt32 fon = 200; + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel); + resolution = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size; + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + StaticData.ValueChanged += (sender1, e1) => + { + imgsearch = StaticData.DataBuffer; + //img_srch.Text = StaticData.DataBuffer.ToString(); + }; + StaticData.SHandlerSearch = new StaticData.SHandler(SearchPixel); + pictureBox1.Image = bm = new Bitmap(pictureBox1.Width, pictureBox1.Height); + StaticData.TrgEventHandler += SearchPixel2; + + } + private void Form1_SizeChanged(object sender, EventArgs e) + { + if (this.WindowState != FormWindowState.Maximized) + { + this.WindowState = FormWindowState.Normal; + this.Size = minform; + this.Location = new Point(resolution.Width / 2 - minform.Width / 2, resolution.Height / 2 - minform.Height / 2); + Console.WriteLine($"{pictureBox1.Size.Width} {pictureBox1.Size.Height} {pictureBox1.Location.X} {pictureBox1.Location.Y}"); + this.CenterToScreen(); + } + else + { + this.WindowState = FormWindowState.Maximized; + this.CenterToScreen(); + Console.WriteLine($"{pictureBox1.Size.Width} {pictureBox1.Size.Height} {pictureBox1.Location.X} {pictureBox1.Location.Y}"); + } + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + } + private void pictureBox1_MouseEnter(object sender, EventArgs e) + { + pictureBox1.MouseWheel += pictureBox1_MouseWheel; + pictureBox1.Cursor = Cursors.Cross; + } + private void pictureBox1_MouseLeave(object sender, EventArgs e) + { + pictureBox1.MouseWheel -= pictureBox1_MouseWheel; + pictureBox1.Cursor = Cursors.Default; + } + private void pictureBox1_MouseWheel(object sender, MouseEventArgs e) + { + pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Normal; + float zf = zoomFactor; + if(bm != null) + { + if (e.Delta > 0 && zoomFactor * bm.Width < 8100) + { + zoomFactor *= 1.1F; + } + if (e.Delta < 0 && zoomFactor * bm.Width > 100) + { + zoomFactor /= 1.1F; + } + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + movingPoint.X -= (int)(bm.Width * zoomFactor - bm.Width * zf) / 2; + movingPoint.Y -= (int)(bm.Height * zoomFactor - bm.Height * zf) / 2; + + pictureBox1.Invalidate(); + } + } + private void pictureBox1_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + //Console.WriteLine($"X={e.X} Y={e.Y} " + + // $"w={bm.Width * zoomFactor} h={bm.Height * zoomFactor} " + // размер картинки + // $"mpx={movingPoint.X} mpy={movingPoint.Y} " + // картинка в боксе + // $"xpos={xPos} ypos={yPos} " + // мышь в боксе + // $"mx={xPos - movingPoint.X} my={yPos - movingPoint.Y} " + // мышь в картинке в боксе + // $"mx={(xPos - movingPoint.X) / zoomFactor} my={(yPos - movingPoint.Y) / zoomFactor} " + // мышь в картинке в боксе + // $"z={zoomFactor}"); + select = true; + startSelPoint = new Point(e.Location.X, e.Location.Y); + stopSelPoint = new Point(e.Location.X, e.Location.Y); + int xx = minmax(0, bm.Width - 1, (int)((xPos - movingPoint.X) / zoomFactor)); + int yy = minmax(0, bm.Height - 1, (int)((yPos - movingPoint.Y) / zoomFactor)); + SelPoint1 = new Point(xx, yy); + SelPoint2 = new Point(xx, yy); + } + if (e.Button == MouseButtons.Middle) + { + panning = true; + startingPoint = new Point(e.Location.X - movingPoint.X, e.Location.Y - movingPoint.Y); + } + } + private void pictureBox1_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + select = false; + int xx = minmax(0, bm.Width - 1, (int)((xPos - movingPoint.X) / zoomFactor)); + int yy = minmax(0, bm.Height - 1, (int)((yPos - movingPoint.Y) / zoomFactor)); + SelPoint2 = new Point(xx, yy); + //Console.WriteLine($"x1 {SelPoint1.X} y1 {SelPoint1.Y} x3 {SelPoint2.X} y3 {SelPoint2.Y}"); + Rectangle r = nrect(SelPoint1, SelPoint2); + Console.WriteLine($"x1 {r.X} y1 {r.Y} x3 {r.X + r.Width} y3 {r.Y + r.Height}"); + MassCenter = CalcCenterMass(r); + Console.WriteLine($"x {MassCenter.X} y {MassCenter.Y}"); + } + if (e.Button == MouseButtons.Middle) + { + panning = false; + } + } + private void pictureBox1_MouseMove(object sender, MouseEventArgs e) + { + xPos = e.X; // мышь в боксе + yPos = e.Y; + if (panning) + { + movingPoint = new Point(e.Location.X - startingPoint.X, e.Location.Y - startingPoint.Y); + pictureBox1.Invalidate(); + } + if (select) + { + stopSelPoint = new Point(e.Location.X, e.Location.Y); + int xx = minmax(0, bm.Width - 1, (int)((xPos - movingPoint.X) / zoomFactor)); + int yy = minmax(0, bm.Height - 1, (int)((yPos - movingPoint.Y) / zoomFactor)); + SelPoint2 = new Point(xx, yy); + //using (Graphics g = pictureBox1.CreateGraphics()) + //{ + // g.DrawRectangle(new Pen(Color.Green, 1), nrect(startSelPoint, stopSelPoint)); + //} + //pictureBox1.Invalidate(); + } + if(bm != null) + { + int xx = minmax(0, bm.Width - 1, (int)((xPos - movingPoint.X) / zoomFactor)); + int yy = minmax(0, bm.Height - 1, (int)((yPos - movingPoint.Y) / zoomFactor)); + img_color.Text = $"R:{bm.GetPixel(xx, yy).R:D3} G:{bm.GetPixel(xx, yy).G:D3} B:{bm.GetPixel(xx, yy).B:D3}"; + img_coord.Text = $"X = {xx:D4} Y = {yy:D4}"; + ttt.Text = $"{movingPoint.X:D4} {movingPoint.Y:D4}"; + yyy.Text = $"{xPos:D4} {yPos:D4}"; + } + } + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + e.Graphics.Clear(Color.White); + if (newbm != null) + e.Graphics.DrawImage(ResizeImage(newbm, zoomFactor), movingPoint); + if (select) + e.Graphics.DrawRectangle(new Pen(Color.Green, 1), nrect(startSelPoint, stopSelPoint)); + if (img_center.Checked) + { + e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), + BmToPb(MassCenter).X, + BmToPb(MassCenter).Y - 20, + BmToPb(MassCenter).X, + BmToPb(MassCenter).Y + 20); + e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), + BmToPb(MassCenter).X - 20, + BmToPb(MassCenter).Y, + BmToPb(MassCenter).X + 20, + BmToPb(MassCenter).Y); + e.Graphics.DrawRectangle(new Pen(Color.LimeGreen, 1), BmToPb(MassCenter).X - 20, BmToPb(MassCenter).Y - 20, 40, 40); + } + GC.Collect(); + } + public Bitmap ResizeImage(Image image, float zoom) + { + var destRect = new Rectangle(0, 0, (int)(image.Width * zoom), (int)(image.Height * zoom)); + var destImage = new Bitmap((int)(image.Width * zoom), (int)(image.Height * zoom)); + + //destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); + + using (var graphics = Graphics.FromImage(destImage)) + { + graphics.CompositingMode = CompositingMode.SourceCopy; + graphics.CompositingQuality = CompositingQuality.HighQuality; + if(img_smooth.Checked) + graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + else + graphics.InterpolationMode = InterpolationMode.NearestNeighbor; + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.PixelOffsetMode = PixelOffsetMode.Half; + + using (var wrapMode = new ImageAttributes()) + { + wrapMode.SetWrapMode(WrapMode.TileFlipXY); + //graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); + graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); + } + } + return destImage; + } + private T minmax(T min, T max, T val) where T : IComparable + { + if (val.CompareTo(min) <= 0) + return min; + if (val.CompareTo(max) > 0) + return max; + return val; + } + private Rectangle nrect(Point p1, Point p3) + { + Rectangle r = Rectangle.Empty; + Point p2 = new Point(p3.X, p1.Y); + Point p4 = new Point(p1.X, p3.Y); + + if (p1.X < p3.X && p1.Y < p3.Y) + return new Rectangle(p1, new Size(p3.X - p1.X, p3.Y - p1.Y)); + if (p1.X < p3.X && p1.Y > p3.Y) + return new Rectangle(p4, new Size(p3.X - p4.X, p1.Y - p4.Y)); + if (p1.X > p3.X && p1.Y < p3.Y) + return new Rectangle(p2, new Size(p1.X - p2.X, p3.Y - p2.Y)); + if (p1.X > p3.X && p1.Y > p3.Y) + return new Rectangle(p3, new Size(p4.X - p3.X, p2.Y - p3.Y)); + return r; + } + private void SearchPixel() + { + List points = new List(); + Stopwatch stopwatch = Stopwatch.StartNew(); + UnsafeBitmap btm = new UnsafeBitmap(bm); + btm.LockBitmap(); + for (int y = 0; y < bm.Height; y++) + { + for (int x = 0; x < bm.Width; x++) + { + PixelData c = btm.GetPixel(x, y); + if (c.blue >= imgsearch) + { + points.Add(new Point(x, y)); + //Console.WriteLine($"{x} {y}"); + } + } + } + stopwatch.Stop(); + Console.WriteLine(stopwatch.Elapsed.ToString()); + btm.Dispose(); + using (Graphics g = Graphics.FromImage(newbm)) + { + //g.Clear(Color.White); + for (int i = 0; i < points.Count; i++) + g.DrawEllipse(new Pen(Color.Red), points[i].X - 5, points[i].Y - 5, 10, 10); + + } + pictureBox1.Invalidate(); + } + private Point CalcCenterMass(Rectangle r) + { + Int32 sX = 0; + Int32 sY = 0; + Int32 sZ = 0; + if (r.Width != 0 && r.Height != 0) + { + UnsafeBitmap btm = new UnsafeBitmap(bm); + btm.LockBitmap(); + Int32 num = 1; + for (int y = r.Y; y < r.Bottom; y++) + { + for (int x = r.X; x < r.Right; x++) + { + PixelData c = btm.GetPixel(x, y); + if (minus_fon.Checked) + { + sX += (Int32)((c.blue - fon) * x); + sY += (Int32)((c.blue - fon) * y); + sZ += (Int32)(c.blue - fon); + } + else + { + sX += (Int32)(c.blue * x); + sY += (Int32)(c.blue * y); + sZ += (Int32)(c.blue); + } + num++; + } + } + //sX /= 255; + //sY /= 255; + //sX /= num - 1; + //sY /= num - 1; + sX /= sZ; + sY /= sZ; + btm.Dispose(); + Console.WriteLine($"num: {num} num2: {r.Width * r.Height} x: {sX} y: {sY}"); + return new Point(sX, sY); + } + else + return Point.Empty; + } + private Point BmToPb(Point p) + { + return new Point((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y)); + } + + #region Меню + private void img_load_Click(object sender, EventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = "bitmap files (*.bmp)|*.bmp|All files (*.*)|*.*"; + if (ofd.ShowDialog() != DialogResult.OK) + return; + bm = (Bitmap)Image.FromFile(ofd.FileNames[0]); + newbm = (Bitmap)bm.Clone(); + img_resolution.Text = $"{bm.Width} X {bm.Height}"; + this.CenterToScreen(); + zoomFactor = (float)pictureBox1.Width / (float)bm.Width; + zoomFactor = 1; + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + //pictureBox1.Image = ZoomControl(bm, zoomFactor); + } + private void exit_Click(object sender, EventArgs e) + { + Application.Exit(); + } + private void развернутьToolStripMenuItem_Click(object sender, EventArgs e) + { + this.WindowState = FormWindowState.Maximized; + this.CenterToScreen(); + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + } + private void свернутьToolStripMenuItem_Click(object sender, EventArgs e) + { + this.WindowState = FormWindowState.Normal; + this.Size = new Size(666, 606); + this.CenterToScreen(); + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + } + private void img_search_Click(object sender, EventArgs e) + { + if (img_search.Checked) + { + img_search.Image = Properties.Resources.CheckBoxChecked; + srch.Show(); + StaticData.Fon?.Invoke(fon); + } + else + { + img_search.Image = Properties.Resources.CheckBoxUnchecked; + srch.Hide(); + } + } + private void img_save_Click(object sender, EventArgs e) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "bitmap files (*.bmp)|*.bmp|All files (*.*)|*.*"; + if (sfd.ShowDialog() != DialogResult.OK) + return; + lock (this) + { + newbm.Save(sfd.FileName, ImageFormat.Bmp); + } + } + private void screenshot_Click(object sender, EventArgs e) + { + using (Bitmap bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height)) + { + using (Graphics g = Graphics.FromImage(bitmap)) + { + g.CopyFromScreen(new Point(this.Bounds.Left + pictureBox1.Left + 9, this.Bounds.Top + pictureBox1.Top + 32), Point.Empty, pictureBox1.Size); + } + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "bitmap files (*.bmp)|*.bmp|All files (*.*)|*.*"; + if (sfd.ShowDialog() != DialogResult.OK) + return; + bitmap.Save(sfd.FileName, ImageFormat.Bmp); + } + } + private void img_smooth_Click(object sender, EventArgs e) + { + if (img_smooth.Checked) + img_smooth.Image = Properties.Resources.CheckBoxChecked; + else + img_smooth.Image = Properties.Resources.CheckBoxUnchecked; + + pictureBox1.Invalidate(); + } + #endregion + + #region Загрузка тестовых картинок + private void img1_Click(object sender, EventArgs e) + { + bm = Properties.Resources.olo_02; + newbm = (Bitmap)bm.Clone(); + img_resolution.Text = $"{bm.Width} X {bm.Height}"; + this.CenterToScreen(); + zoomFactor = 1; + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + imgfon(); + } + private void img2_Click(object sender, EventArgs e) + { + bm = Properties.Resources.olo_03; + newbm = (Bitmap)bm.Clone(); + img_resolution.Text = $"{bm.Width} X {bm.Height}"; + this.CenterToScreen(); + zoomFactor = 1; + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + imgfon(); + } + private void img3_Click(object sender, EventArgs e) + { + bm = Properties.Resources.t1_320x256; + newbm = (Bitmap)bm.Clone(); + img_resolution.Text = $"{bm.Width} X {bm.Height}"; + this.CenterToScreen(); + zoomFactor = 1; + img_aspect.Text = $"Аспект: {zoomFactor:F3}"; + movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); + pictureBox1.Invalidate(); + imgfon(); + } + #endregion + + private void SearchPixel2() + { + } + + private void img_fon_Click(object sender, EventArgs e) + { + UnsafeBitmap btm = new UnsafeBitmap(bm); + btm.LockBitmap(); + UInt32 sc = 0; + for (int y = 0; y < bm.Height; y++) + { + PixelData c = btm.GetPixel(y, y); + sc += (UInt32)(c.blue * c.blue); + c = btm.GetPixel(bm.Width - 1 - y, y); + sc += (UInt32)(c.blue * c.blue); + } + Console.WriteLine(sc.ToString()); + sc = (UInt32)Math.Sqrt(sc / bm.Height / 2); + Console.WriteLine(sc.ToString()); + + img_srch.Text = $"Фон: {sc}"; + btm.UnlockBitmap(); + btm.Dispose(); + fon = sc; + StaticData.Fon?.Invoke(sc); + } + private void imgfon() + { + UnsafeBitmap btm = new UnsafeBitmap(bm); + btm.LockBitmap(); + UInt32 sc = 0; + for (int y = 0; y < bm.Height; y++) + { + PixelData c = btm.GetPixel(y, y); + sc += (UInt32)(c.blue * c.blue); + c = btm.GetPixel(bm.Width - 1 - y, y); + sc += (UInt32)(c.blue * c.blue); + } + Console.WriteLine(sc.ToString()); + sc = (UInt32)Math.Sqrt(sc / bm.Height / 2); + Console.WriteLine(sc.ToString()); + + img_srch.Text = $"Фон: {sc}"; + btm.UnlockBitmap(); + btm.Dispose(); + fon = sc; + StaticData.Fon?.Invoke(sc); + } + + private void img_timer_Click(object sender, EventArgs e) + { + if (img_timer.Checked) + { + img_timer.Image = Properties.Resources.CheckBoxChecked; + timer1.Enabled = true; + } + else + { + img_timer.Image = Properties.Resources.CheckBoxUnchecked; + timer1.Enabled = false; + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + newbm = (Bitmap)bm.Clone(); + if (img_search.Checked) + { + SearchPixel(); + } + pictureBox1.Invalidate(); + } + + private void img_center_Click(object sender, EventArgs e) + { + if (img_center.Checked) + { + img_center.Image = Properties.Resources.CheckBoxChecked; + } + else + { + img_center.Image = Properties.Resources.CheckBoxUnchecked; + } + } + + private void minus_fon_Click(object sender, EventArgs e) + { + if (minus_fon.Checked) + { + minus_fon.Image = Properties.Resources.CheckBoxChecked; + } + else + { + minus_fon.Image = Properties.Resources.CheckBoxUnchecked; + } + } + } +} diff --git a/Test_img/Form1.resx b/Test_img/Form1.resx new file mode 100644 index 0000000..d011faa --- /dev/null +++ b/Test_img/Form1.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 18, 0 + + + 127, 3 + + + 210, 3 + + + 59 + + \ No newline at end of file diff --git a/Test_img/Program.cs b/Test_img/Program.cs new file mode 100644 index 0000000..fc95056 --- /dev/null +++ b/Test_img/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Test_img +{ + internal static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Test_img/Properties/AssemblyInfo.cs b/Test_img/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..62ccdba --- /dev/null +++ b/Test_img/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("Test_img")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test_img")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("ae96c475-3f2e-409c-9213-a049fb9cad10")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Test_img/Properties/Resources.Designer.cs b/Test_img/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7d678b0 --- /dev/null +++ b/Test_img/Properties/Resources.Designer.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Test_img.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_img.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap CheckBoxChecked { + get { + object obj = ResourceManager.GetObject("CheckBoxChecked", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap CheckBoxUnchecked { + get { + object obj = ResourceManager.GetObject("CheckBoxUnchecked", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap i1 { + get { + object obj = ResourceManager.GetObject("i1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap olo_02 { + get { + object obj = ResourceManager.GetObject("olo_02", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap olo_03 { + get { + object obj = ResourceManager.GetObject("olo_03", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap t1_320x256 { + get { + object obj = ResourceManager.GetObject("t1_320x256", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Test_img/Properties/Resources.resx b/Test_img/Properties/Resources.resx new file mode 100644 index 0000000..becab90 --- /dev/null +++ b/Test_img/Properties/Resources.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\olo_03.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\t1-320x256.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\olo_02.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\i1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\CheckBoxChecked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\CheckBoxUnchecked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Test_img/Properties/Settings.Designer.cs b/Test_img/Properties/Settings.Designer.cs new file mode 100644 index 0000000..13223f2 --- /dev/null +++ b/Test_img/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Test_img.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Test_img/Properties/Settings.settings b/Test_img/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Test_img/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Test_img/Resources/CheckBoxChecked.png b/Test_img/Resources/CheckBoxChecked.png new file mode 100644 index 0000000..c32c15f Binary files /dev/null and b/Test_img/Resources/CheckBoxChecked.png differ diff --git a/Test_img/Resources/CheckBoxUnchecked.png b/Test_img/Resources/CheckBoxUnchecked.png new file mode 100644 index 0000000..9814763 Binary files /dev/null and b/Test_img/Resources/CheckBoxUnchecked.png differ diff --git a/Test_img/Resources/i1.png b/Test_img/Resources/i1.png new file mode 100644 index 0000000..e2b328d Binary files /dev/null and b/Test_img/Resources/i1.png differ diff --git a/Test_img/Resources/olo_02.bmp b/Test_img/Resources/olo_02.bmp new file mode 100644 index 0000000..83011b1 Binary files /dev/null and b/Test_img/Resources/olo_02.bmp differ diff --git a/Test_img/Resources/olo_03.bmp b/Test_img/Resources/olo_03.bmp new file mode 100644 index 0000000..dcdd0cb Binary files /dev/null and b/Test_img/Resources/olo_03.bmp differ diff --git a/Test_img/Resources/t1-320x256.bmp b/Test_img/Resources/t1-320x256.bmp new file mode 100644 index 0000000..f490426 Binary files /dev/null and b/Test_img/Resources/t1-320x256.bmp differ diff --git a/Test_img/Test_img.csproj b/Test_img/Test_img.csproj new file mode 100644 index 0000000..f351f8e --- /dev/null +++ b/Test_img/Test_img.csproj @@ -0,0 +1,114 @@ + + + + + Debug + AnyCPU + {AE96C475-3F2E-409C-9213-A049FB9CAD10} + WinExe + Test_img + Test_img + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form + + + search.cs + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + search.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test_img/UnsafeBitmap.cs b/Test_img/UnsafeBitmap.cs new file mode 100644 index 0000000..51b9d98 --- /dev/null +++ b/Test_img/UnsafeBitmap.cs @@ -0,0 +1,92 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; + +namespace UTIL +{ + public unsafe class UnsafeBitmap + { + Bitmap bitmap; + // three elements used for MakeGreyUnsafe + int width; + BitmapData bitmapData = null; + Byte* pBase = null; + public UnsafeBitmap(Bitmap bitmap) + { + this.bitmap = new Bitmap(bitmap); + } + public UnsafeBitmap(int width, int height) + { + this.bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb); + } + public void Dispose() + { + bitmap.Dispose(); + } + public Bitmap Bitmap + { + get + { + return (bitmap); + } + } + private Point PixelSize + { + get + { + GraphicsUnit unit = GraphicsUnit.Pixel; + RectangleF bounds = bitmap.GetBounds(ref unit); + + return new Point((int)bounds.Width, (int)bounds.Height); + } + } + public void LockBitmap() + { + GraphicsUnit unit = GraphicsUnit.Pixel; + RectangleF boundsF = bitmap.GetBounds(ref unit); + Rectangle bounds = new Rectangle((int)boundsF.X, + (int)boundsF.Y, + (int)boundsF.Width, + (int)boundsF.Height); + + // Figure out the number of bytes in a row + // This is rounded up to be a multiple of 4 + // bytes, since a scan line in an image must always be a multiple of 4 bytes + // in length. + width = (int)boundsF.Width * sizeof(PixelData); + if (width % 4 != 0) + { + width = 4 * (width / 4 + 1); + } + bitmapData = + bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); + pBase = (Byte*)bitmapData.Scan0.ToPointer(); + } + public PixelData GetPixel(int x, int y) + { + PixelData returnValue = *PixelAt(x, y); + return returnValue; + } + public void SetPixel(int x, int y, PixelData colour) + { + PixelData* pixel = PixelAt(x, y); + *pixel = colour; + } + public void UnlockBitmap() + { + bitmap.UnlockBits(bitmapData); + bitmapData = null; + pBase = null; + } + public PixelData* PixelAt(int x, int y) + { + return (PixelData*)(pBase + y * width + x * sizeof(PixelData)); + } + } + public struct PixelData + { + public byte blue; + public byte green; + public byte red; + } +} diff --git a/Test_img/data.cs b/Test_img/data.cs new file mode 100644 index 0000000..efb10e4 --- /dev/null +++ b/Test_img/data.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Test_img +{ + public class DData + { + } + public static class StaticData + { + public delegate void ValueChangedEventHandler(object sender, EventArgs e); + public static event ValueChangedEventHandler ValueChanged; + + public delegate void FonEventHandler(UInt32 fon); + public static FonEventHandler Fon; + + public delegate void TrgHandler(); + public static event TrgHandler TrgEventHandler; + + public delegate void SHandler(); + public static SHandler SHandlerSearch; + + private static int dataBuffer = 0; + public static void Trg() + { + TrgEventHandler?.Invoke(); + } + public static int DataBuffer + { + get + { + return dataBuffer; + } + set + { + dataBuffer = value; + ValueChanged(null, EventArgs.Empty); + } + } + } +} diff --git a/Test_img/search.Designer.cs b/Test_img/search.Designer.cs new file mode 100644 index 0000000..ae7e584 --- /dev/null +++ b/Test_img/search.Designer.cs @@ -0,0 +1,85 @@ +namespace Test_img +{ + partial class search + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.trackBar1 = new System.Windows.Forms.TrackBar(); + this.label1 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); + this.SuspendLayout(); + // + // trackBar1 + // + this.trackBar1.AutoSize = false; + this.trackBar1.Location = new System.Drawing.Point(13, 4); + this.trackBar1.Maximum = 255; + this.trackBar1.Name = "trackBar1"; + this.trackBar1.Size = new System.Drawing.Size(310, 33); + this.trackBar1.TabIndex = 0; + this.trackBar1.TickFrequency = 10; + this.trackBar1.Value = 200; + this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label1.Location = new System.Drawing.Point(329, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(31, 16); + this.label1.TabIndex = 1; + this.label1.Text = "200"; + // + // search + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(368, 40); + this.ControlBox = false; + this.Controls.Add(this.label1); + this.Controls.Add(this.trackBar1); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "search"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "search"; + this.Load += new System.EventHandler(this.search_Load); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TrackBar trackBar1; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/Test_img/search.cs b/Test_img/search.cs new file mode 100644 index 0000000..dd1b8da --- /dev/null +++ b/Test_img/search.cs @@ -0,0 +1,45 @@ +using System; +using System.Windows.Forms; + +namespace Test_img +{ + public partial class search : Form + { + public search() + { + InitializeComponent(); + } + + private void trackBar1_Scroll(object sender, EventArgs e) + { + label1.Text = trackBar1.Value.ToString(); + StaticData.DataBuffer = trackBar1.Value; + } + + private void button1_Click(object sender, EventArgs e) + { + //StaticData.Start = ""; + //StaticData.SHandlerSearch?.Invoke(); + //StaticData.Trg(); + // StaticData.SHandlerSearch += true; + } + + private void search_Load(object sender, EventArgs e) + { + StaticData.Fon = new StaticData.FonEventHandler(newfon); + + //StaticData.Fon += (ee) => + //{ + // trackBar1.Value = (int)ee + 5; + // label1.Text = (int)ee + 5.ToString(); + //}; + + } + private void newfon(UInt32 ee) + { + trackBar1.Minimum = (int)ee; + trackBar1.Value = (int)ee + 1; + label1.Text = ((int)ee + 1).ToString(); + } + } +} diff --git a/Test_img/search.resx b/Test_img/search.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Test_img/search.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/i1.png b/i1.png new file mode 100644 index 0000000..e2b328d Binary files /dev/null and b/i1.png differ diff --git a/olo_01.bmp b/olo_01.bmp new file mode 100644 index 0000000..c349c75 Binary files /dev/null and b/olo_01.bmp differ diff --git a/olo_02.bmp b/olo_02.bmp new file mode 100644 index 0000000..83011b1 Binary files /dev/null and b/olo_02.bmp differ diff --git a/olo_03.bmp b/olo_03.bmp new file mode 100644 index 0000000..dcdd0cb Binary files /dev/null and b/olo_03.bmp differ diff --git a/t4/01.bmp b/t4/01.bmp new file mode 100644 index 0000000..a50d30c Binary files /dev/null and b/t4/01.bmp differ diff --git a/t4/02.bmp b/t4/02.bmp new file mode 100644 index 0000000..23d8644 Binary files /dev/null and b/t4/02.bmp differ diff --git a/t4/11.bmp b/t4/11.bmp new file mode 100644 index 0000000..b0e9472 Binary files /dev/null and b/t4/11.bmp differ diff --git a/t4/12.bmp b/t4/12.bmp new file mode 100644 index 0000000..80b2779 Binary files /dev/null and b/t4/12.bmp differ diff --git a/t4/21.bmp b/t4/21.bmp new file mode 100644 index 0000000..d9acb81 Binary files /dev/null and b/t4/21.bmp differ diff --git a/t4/22.bmp b/t4/22.bmp new file mode 100644 index 0000000..7d3c0ce Binary files /dev/null and b/t4/22.bmp differ diff --git a/t4/32.bmp b/t4/32.bmp new file mode 100644 index 0000000..b541132 Binary files /dev/null and b/t4/32.bmp differ diff --git a/t4/41.bmp b/t4/41.bmp new file mode 100644 index 0000000..d6ffa57 Binary files /dev/null and b/t4/41.bmp differ diff --git a/t4/51.bmp b/t4/51.bmp new file mode 100644 index 0000000..5210df9 Binary files /dev/null and b/t4/51.bmp differ diff --git a/t4/61.bmp b/t4/61.bmp new file mode 100644 index 0000000..de57b12 Binary files /dev/null and b/t4/61.bmp differ diff --git a/t4/ConsoleApplication1.exe b/t4/ConsoleApplication1.exe new file mode 100644 index 0000000..a3e599b Binary files /dev/null and b/t4/ConsoleApplication1.exe differ diff --git a/test_image_processing_1/test_image_processing_1.sln b/test_image_processing_1/test_image_processing_1.sln new file mode 100644 index 0000000..03e3e61 --- /dev/null +++ b/test_image_processing_1/test_image_processing_1.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test_image_processing_1", "test_image_processing_1\test_image_processing_1.csproj", "{5238A504-9522-4F92-82F1-0D7A3C52125A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5238A504-9522-4F92-82F1-0D7A3C52125A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5238A504-9522-4F92-82F1-0D7A3C52125A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5238A504-9522-4F92-82F1-0D7A3C52125A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5238A504-9522-4F92-82F1-0D7A3C52125A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test_image_processing_1/test_image_processing_1/Program.cs b/test_image_processing_1/test_image_processing_1/Program.cs new file mode 100644 index 0000000..ba24257 --- /dev/null +++ b/test_image_processing_1/test_image_processing_1/Program.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + + +namespace test_image_processing_1 +{ + public class cnst + { + public const ushort BAD_PIXELS_ARRAY_SIZE = 256; + public const ushort SN_LENGTH = 128; + public const ushort NO_MARKER = 0; // 'no marker' cluster identifier + public const ushort REASON_BY_REQUEST = 0x0; // output status message initiated by host request + public const ushort REASON_BY_TIMER = 0x1; // output status message initiated by timer event + public const ushort REASON_BY_STATE = 0x2; // output status message initiated by state change + + public const ushort MODE_OPERATIONAL = 0x1; // normal mode + public const ushort MODE_PROGRAMMING = 0x2; // device is being programmed + } + class Program + { + public struct FIFO_ITEM + { + public ushort x; + public ushort y; + } + + //public struct BAD_PIX_FILE_STRUCTURE + //{ + // public ushort count; + // public fixed FIFO_ITEM array[256]; + //} + + unsafe public struct CONFIG_FILE_STRUCTURE + { + public fixed byte szSerialNumber[128];// matrix serial number, zero-terminated string + public ushort nXc, nYc; // centers of matrices, pix + public ushort nRs, nRb; // lens field of view radius ('s'=small, 'b'=big), pix + public byte cLc; // neighbour distance for clasters, pix + public ushort nLimit; // FIFO limit (10-bit) + public ushort nVinb, nVref; // VINB & VREF (10-bit) + public float fA, fB, fC; // Fi=A*x^2 + Bx + C + } + unsafe public struct THE_POINT + { + public FIFO_ITEM *pi; + public byte *pm; + } + public struct CLUSTER_COORD + { + public ushort count; // number of points (pixels) in cluster + public byte excluded; // flag, cluster should be ignored if TRUE + public byte marker; // cluster identicator + public ARM_RECT rect; // rectangular area of cluster (in pixels) + } + public struct ARM_RECT + { + public ushort left; + public ushort top; + public ushort right; + public ushort bottom; + } + unsafe void CopyRect(ARM_RECT *dst, ARM_RECT *src) + { + dst->left = src->left; + dst->top = src->top; + dst->right = src->right; + dst->bottom = src->bottom; + } + unsafe bool EmptyRect(ARM_RECT *r) + { + return !(((int)r->right - (int)r->left) > 0 && + ((int)r->bottom - (int)r->top) > 0); + } + unsafe bool IntersectRect(ARM_RECT *r, ARM_RECT *r1, ARM_RECT *r2) + { + ARM_RECT rect; + CopyRect(&rect, r1); + if(r2->left > r1->left ) rect.left = r2->left; + if(r2->top > r1->top ) rect.top = r2->top; + if(r2->right < r1->right ) rect.right = r2->right; + if(r2->bottom < r1->bottom) rect.bottom = r2->bottom; + if(r != null) + *r = rect; + return !EmptyRect(&rect); + } + unsafe void make_point(FIFO_ITEM *pi, byte *pm, THE_POINT *point) + { + point->pi = pi; + point->pm = pm; + } + unsafe bool neighbour_points(THE_POINT *p1, THE_POINT *p2, byte length) + { + return (Math.Abs((short)p2->pi->x - (short)p1->pi->x) <= length) && + (Math.Abs((short)p2->pi->y - (short)p1->pi->y) <= length); + } + unsafe bool point_has_no_marker(THE_POINT *p) + { + return *(p->pm) == cnst.NO_MARKER; + } + unsafe void copy_marker(THE_POINT *dst, THE_POINT *src) + { + *(dst->pm) = *(src->pm); + } + public struct COORDS_DATA + { + uint time; // time of alarm, in 10us units + short angle1; // + short angle2; // + } + + static void Main(string[] args) + { + } + } +} diff --git a/test_image_processing_1/test_image_processing_1/Properties/AssemblyInfo.cs b/test_image_processing_1/test_image_processing_1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5dd80bb --- /dev/null +++ b/test_image_processing_1/test_image_processing_1/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Управление общими сведениями о сборке осуществляется с помощью +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("test_image_processing_1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("test_image_processing_1")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми +// для COM-компонентов. Если требуется обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("b51ddaea-c0e5-43af-a807-e43e87a7df42")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test_image_processing_1/test_image_processing_1/test_image_processing_1.csproj b/test_image_processing_1/test_image_processing_1/test_image_processing_1.csproj new file mode 100644 index 0000000..da9f19a --- /dev/null +++ b/test_image_processing_1/test_image_processing_1/test_image_processing_1.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {5238A504-9522-4F92-82F1-0D7A3C52125A} + Exe + Properties + test_image_processing_1 + test_image_processing_1 + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test_image_processing_2/pic/1/2011.03.17_09.15.16.250.bmp b/test_image_processing_2/pic/1/2011.03.17_09.15.16.250.bmp new file mode 100644 index 0000000..d6c8e9b Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.15.16.250.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.15.44.234.bmp b/test_image_processing_2/pic/1/2011.03.17_09.15.44.234.bmp new file mode 100644 index 0000000..2c1af67 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.15.44.234.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.15.52.828.bmp b/test_image_processing_2/pic/1/2011.03.17_09.15.52.828.bmp new file mode 100644 index 0000000..ff36e6e Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.15.52.828.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.15.55.796.bmp b/test_image_processing_2/pic/1/2011.03.17_09.15.55.796.bmp new file mode 100644 index 0000000..48f795c Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.15.55.796.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.04.921.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.04.921.bmp new file mode 100644 index 0000000..9843afe Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.04.921.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.07.187.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.07.187.bmp new file mode 100644 index 0000000..24d6f6a Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.07.187.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.21.781.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.21.781.bmp new file mode 100644 index 0000000..d184e39 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.21.781.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.28.609.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.28.609.bmp new file mode 100644 index 0000000..bc4b289 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.28.609.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.37.843.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.37.843.bmp new file mode 100644 index 0000000..b367f4f Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.37.843.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.16.46.437.bmp b/test_image_processing_2/pic/1/2011.03.17_09.16.46.437.bmp new file mode 100644 index 0000000..9fc68a2 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.16.46.437.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.17.16.078.bmp b/test_image_processing_2/pic/1/2011.03.17_09.17.16.078.bmp new file mode 100644 index 0000000..42233d8 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.17.16.078.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.17.24.734.bmp b/test_image_processing_2/pic/1/2011.03.17_09.17.24.734.bmp new file mode 100644 index 0000000..7acb4ce Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.17.24.734.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.17.35.921.bmp b/test_image_processing_2/pic/1/2011.03.17_09.17.35.921.bmp new file mode 100644 index 0000000..812704f Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.17.35.921.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.17.46.375.bmp b/test_image_processing_2/pic/1/2011.03.17_09.17.46.375.bmp new file mode 100644 index 0000000..ea39d53 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.17.46.375.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.17.57.265.bmp b/test_image_processing_2/pic/1/2011.03.17_09.17.57.265.bmp new file mode 100644 index 0000000..3a89aba Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.17.57.265.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.18.07.765.bmp b/test_image_processing_2/pic/1/2011.03.17_09.18.07.765.bmp new file mode 100644 index 0000000..1944205 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.18.07.765.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.18.15.078.bmp b/test_image_processing_2/pic/1/2011.03.17_09.18.15.078.bmp new file mode 100644 index 0000000..e852fff Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.18.15.078.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.18.25.609.bmp b/test_image_processing_2/pic/1/2011.03.17_09.18.25.609.bmp new file mode 100644 index 0000000..1de6b57 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.18.25.609.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.18.43.312.bmp b/test_image_processing_2/pic/1/2011.03.17_09.18.43.312.bmp new file mode 100644 index 0000000..8e61edd Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.18.43.312.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.33.20.609.bmp b/test_image_processing_2/pic/1/2011.03.17_09.33.20.609.bmp new file mode 100644 index 0000000..b8e2ff0 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.33.20.609.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.33.41.921.bmp b/test_image_processing_2/pic/1/2011.03.17_09.33.41.921.bmp new file mode 100644 index 0000000..42dba01 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.33.41.921.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.33.49.609.bmp b/test_image_processing_2/pic/1/2011.03.17_09.33.49.609.bmp new file mode 100644 index 0000000..6d64f2f Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.33.49.609.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.34.05.328.bmp b/test_image_processing_2/pic/1/2011.03.17_09.34.05.328.bmp new file mode 100644 index 0000000..1eea008 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.34.05.328.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.34.08.578.bmp b/test_image_processing_2/pic/1/2011.03.17_09.34.08.578.bmp new file mode 100644 index 0000000..9d1eea6 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.34.08.578.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.34.25.078.bmp b/test_image_processing_2/pic/1/2011.03.17_09.34.25.078.bmp new file mode 100644 index 0000000..83a38f6 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.34.25.078.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.34.32.796.bmp b/test_image_processing_2/pic/1/2011.03.17_09.34.32.796.bmp new file mode 100644 index 0000000..4a9ba64 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.34.32.796.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.03.453.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.03.453.bmp new file mode 100644 index 0000000..753bd66 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.03.453.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.09.859.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.09.859.bmp new file mode 100644 index 0000000..cd1afef Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.09.859.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.19.359.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.19.359.bmp new file mode 100644 index 0000000..5bf0a09 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.19.359.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.24.171.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.24.171.bmp new file mode 100644 index 0000000..cbe9c98 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.24.171.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.25.203.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.25.203.bmp new file mode 100644 index 0000000..cbe9c98 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.25.203.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.27.656.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.27.656.bmp new file mode 100644 index 0000000..5ce6661 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.27.656.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.33.906.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.33.906.bmp new file mode 100644 index 0000000..de1a5e8 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.33.906.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.38.828.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.38.828.bmp new file mode 100644 index 0000000..6ee5b99 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.38.828.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.41.812.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.41.812.bmp new file mode 100644 index 0000000..1e76391 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.41.812.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.48.187.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.48.187.bmp new file mode 100644 index 0000000..9913f1d Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.48.187.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.38.57.750.bmp b/test_image_processing_2/pic/1/2011.03.17_09.38.57.750.bmp new file mode 100644 index 0000000..b53fe2e Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.38.57.750.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.39.04.296.bmp b/test_image_processing_2/pic/1/2011.03.17_09.39.04.296.bmp new file mode 100644 index 0000000..b45919e Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.39.04.296.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.40.40.265.bmp b/test_image_processing_2/pic/1/2011.03.17_09.40.40.265.bmp new file mode 100644 index 0000000..3e75a8f Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.40.40.265.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.40.51.765.bmp b/test_image_processing_2/pic/1/2011.03.17_09.40.51.765.bmp new file mode 100644 index 0000000..99a4a8a Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.40.51.765.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.41.07.140.bmp b/test_image_processing_2/pic/1/2011.03.17_09.41.07.140.bmp new file mode 100644 index 0000000..ab8cee8 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.41.07.140.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.41.43.796.bmp b/test_image_processing_2/pic/1/2011.03.17_09.41.43.796.bmp new file mode 100644 index 0000000..a624a9c Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.41.43.796.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_09.41.53.421.bmp b/test_image_processing_2/pic/1/2011.03.17_09.41.53.421.bmp new file mode 100644 index 0000000..3ee6b82 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_09.41.53.421.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.17.19.093.bmp b/test_image_processing_2/pic/1/2011.03.17_10.17.19.093.bmp new file mode 100644 index 0000000..14b0ca5 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.17.19.093.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.17.24.781.bmp b/test_image_processing_2/pic/1/2011.03.17_10.17.24.781.bmp new file mode 100644 index 0000000..4c9a9ac Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.17.24.781.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.17.28.406.bmp b/test_image_processing_2/pic/1/2011.03.17_10.17.28.406.bmp new file mode 100644 index 0000000..393b283 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.17.28.406.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.17.32.734.bmp b/test_image_processing_2/pic/1/2011.03.17_10.17.32.734.bmp new file mode 100644 index 0000000..3c97ad1 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.17.32.734.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.17.40.734.bmp b/test_image_processing_2/pic/1/2011.03.17_10.17.40.734.bmp new file mode 100644 index 0000000..82c5815 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.17.40.734.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.19.54.703.bmp b/test_image_processing_2/pic/1/2011.03.17_10.19.54.703.bmp new file mode 100644 index 0000000..135e93f Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.19.54.703.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.20.07.218.bmp b/test_image_processing_2/pic/1/2011.03.17_10.20.07.218.bmp new file mode 100644 index 0000000..b6aa046 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.20.07.218.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.20.09.437.bmp b/test_image_processing_2/pic/1/2011.03.17_10.20.09.437.bmp new file mode 100644 index 0000000..a49d519 Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.20.09.437.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.20.13.531.bmp b/test_image_processing_2/pic/1/2011.03.17_10.20.13.531.bmp new file mode 100644 index 0000000..0a405cf Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.20.13.531.bmp differ diff --git a/test_image_processing_2/pic/1/2011.03.17_10.20.18.484.bmp b/test_image_processing_2/pic/1/2011.03.17_10.20.18.484.bmp new file mode 100644 index 0000000..a04f48a Binary files /dev/null and b/test_image_processing_2/pic/1/2011.03.17_10.20.18.484.bmp differ diff --git a/test_image_processing_2/pic/test_11.bmp b/test_image_processing_2/pic/test_11.bmp new file mode 100644 index 0000000..4d5512e Binary files /dev/null and b/test_image_processing_2/pic/test_11.bmp differ diff --git a/test_image_processing_2/pic/test_11.pix b/test_image_processing_2/pic/test_11.pix new file mode 100644 index 0000000..978433d --- /dev/null +++ b/test_image_processing_2/pic/test_11.pix @@ -0,0 +1,33 @@ +47 166 231 +63 133 231 +63 134 231 +64 133 232 +64 134 229 +64 135 227 +64 136 229 +65 135 228 +65 136 230 +65 165 176 +65 166 92 +66 136 227 +77 143 180 +88 195 80 +90 195 208 +145 112 228 +148 69 125 +175 116 220 +176 115 144 +176 116 228 +177 115 230 +177 116 231 +177 117 231 +177 118 114 +178 115 180 +178 116 230 +178 117 147 +183 71 231 +221 220 144 +222 220 84 +223 215 201 +298 218 228 +308 111 150 diff --git a/test_image_processing_2/pic/test_12.bmp b/test_image_processing_2/pic/test_12.bmp new file mode 100644 index 0000000..2c1af67 Binary files /dev/null and b/test_image_processing_2/pic/test_12.bmp differ diff --git a/test_image_processing_2/pic/test_21.bmp b/test_image_processing_2/pic/test_21.bmp new file mode 100644 index 0000000..9d2cde5 Binary files /dev/null and b/test_image_processing_2/pic/test_21.bmp differ diff --git a/test_image_processing_2/pic/test_21.pix b/test_image_processing_2/pic/test_21.pix new file mode 100644 index 0000000..49fb7dc --- /dev/null +++ b/test_image_processing_2/pic/test_21.pix @@ -0,0 +1,33 @@ +47 166 231 +63 133 231 +63 134 230 +64 133 230 +64 134 230 +64 135 228 +64 136 230 +65 135 229 +65 136 229 +65 165 172 +65 166 94 +66 136 228 +77 143 181 +90 195 208 +145 112 229 +148 69 88 +175 116 221 +176 115 144 +176 116 229 +177 115 230 +177 116 231 +177 117 231 +177 118 109 +178 115 181 +178 116 231 +178 117 148 +183 71 231 +211 82 81 +221 220 143 +222 220 85 +223 215 200 +298 218 227 +308 111 148 diff --git a/test_image_processing_2/pic/test_22.bmp b/test_image_processing_2/pic/test_22.bmp new file mode 100644 index 0000000..24d6f6a Binary files /dev/null and b/test_image_processing_2/pic/test_22.bmp differ diff --git a/test_image_processing_2/pic/test_31.bmp b/test_image_processing_2/pic/test_31.bmp new file mode 100644 index 0000000..810e72c Binary files /dev/null and b/test_image_processing_2/pic/test_31.bmp differ diff --git a/test_image_processing_2/pic/test_32.bmp b/test_image_processing_2/pic/test_32.bmp new file mode 100644 index 0000000..b367f4f Binary files /dev/null and b/test_image_processing_2/pic/test_32.bmp differ diff --git a/test_image_processing_2/test_image_processing_2.sln b/test_image_processing_2/test_image_processing_2.sln new file mode 100644 index 0000000..6745ce5 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test_image_processing_2", "test_image_processing_2\test_image_processing_2.csproj", "{A7DB8256-E90B-45F5-913E-B9CF9138E509}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A7DB8256-E90B-45F5-913E-B9CF9138E509}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7DB8256-E90B-45F5-913E-B9CF9138E509}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7DB8256-E90B-45F5-913E-B9CF9138E509}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7DB8256-E90B-45F5-913E-B9CF9138E509}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/test_image_processing_2/test_image_processing_2/Form1.Designer.cs b/test_image_processing_2/test_image_processing_2/Form1.Designer.cs new file mode 100644 index 0000000..e4a8d93 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Form1.Designer.cs @@ -0,0 +1,403 @@ +namespace test_image_processing_2 +{ + partial class Form1 + { + /// + /// Требуется переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Обязательный метод для поддержки конструктора - не изменяйте + /// содержимое данного метода при помощи редактора кода. + /// + private void InitializeComponent() + { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.trackBar1 = new System.Windows.Forms.TrackBar(); + this.label2 = new System.Windows.Forms.Label(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.listBox2 = new System.Windows.Forms.ListBox(); + this.listBox3 = new System.Windows.Forms.ListBox(); + this.button2 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.checkBox3 = new System.Windows.Forms.CheckBox(); + this.trackBar2 = new System.Windows.Forms.TrackBar(); + this.label5 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.listBox4 = new System.Windows.Forms.ListBox(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.checkBox4 = new System.Windows.Forms.CheckBox(); + this.label6 = new System.Windows.Forms.Label(); + this.checkBox5 = new System.Windows.Forms.CheckBox(); + this.label7 = new System.Windows.Forms.Label(); + this.trackBar3 = new System.Windows.Forms.TrackBar(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBox1.Location = new System.Drawing.Point(12, 39); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(320, 256); + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(338, 39); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(152, 121); + this.listBox1.TabIndex = 1; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(94, 12); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(577, 20); + this.textBox1.TabIndex = 2; + this.textBox1.DoubleClick += new System.EventHandler(this.textBox1_DoubleClick); + // + // trackBar1 + // + this.trackBar1.AutoSize = false; + this.trackBar1.Location = new System.Drawing.Point(64, 319); + this.trackBar1.Maximum = 255; + this.trackBar1.Name = "trackBar1"; + this.trackBar1.Size = new System.Drawing.Size(240, 23); + this.trackBar1.TabIndex = 5; + this.trackBar1.TickFrequency = 5; + this.trackBar1.Value = 80; + this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(310, 319); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(56, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Порог: 80"; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(12, 318); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(45, 17); + this.checkBox1.TabIndex = 7; + this.checkBox1.Text = "Bad"; + this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // + // pictureBox2 + // + this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBox2.Location = new System.Drawing.Point(496, 38); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(320, 256); + this.pictureBox2.TabIndex = 8; + this.pictureBox2.TabStop = false; + // + // listBox2 + // + this.listBox2.FormattingEnabled = true; + this.listBox2.Location = new System.Drawing.Point(822, 39); + this.listBox2.Name = "listBox2"; + this.listBox2.Size = new System.Drawing.Size(154, 121); + this.listBox2.TabIndex = 9; + this.listBox2.SelectedIndexChanged += new System.EventHandler(this.listBox2_SelectedIndexChanged); + // + // listBox3 + // + this.listBox3.FormattingEnabled = true; + this.listBox3.Location = new System.Drawing.Point(336, 166); + this.listBox3.Name = "listBox3"; + this.listBox3.Size = new System.Drawing.Size(154, 121); + this.listBox3.TabIndex = 10; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(13, 12); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 21); + this.button2.TabIndex = 11; + this.button2.Text = "Путь:"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(377, 320); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(54, 13); + this.label1.TabIndex = 12; + this.label1.Text = "Bad pix: 0"; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(449, 318); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(38, 17); + this.checkBox2.TabIndex = 13; + this.checkBox2.Text = "Fill"; + this.checkBox2.UseVisualStyleBackColor = true; + this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); + // + // label3 + // + this.label3.Location = new System.Drawing.Point(12, 298); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(320, 19); + this.label3.TabIndex = 14; + this.label3.Text = "label3"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(496, 298); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(320, 19); + this.label4.TabIndex = 15; + this.label4.Text = "label4"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // checkBox3 + // + this.checkBox3.AutoSize = true; + this.checkBox3.Location = new System.Drawing.Point(12, 348); + this.checkBox3.Name = "checkBox3"; + this.checkBox3.Size = new System.Drawing.Size(86, 17); + this.checkBox3.TabIndex = 16; + this.checkBox3.Text = "Убрать фон"; + this.checkBox3.UseVisualStyleBackColor = true; + this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged); + // + // trackBar2 + // + this.trackBar2.AutoSize = false; + this.trackBar2.Location = new System.Drawing.Point(94, 348); + this.trackBar2.Maximum = 255; + this.trackBar2.Name = "trackBar2"; + this.trackBar2.Size = new System.Drawing.Size(337, 23); + this.trackBar2.TabIndex = 17; + this.trackBar2.TickFrequency = 5; + this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(437, 349); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(50, 13); + this.label5.TabIndex = 18; + this.label5.Text = "Порог: 0"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(415, 293); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 21); + this.button1.TabIndex = 19; + this.button1.Text = "Save bad"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click_1); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(336, 293); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 21); + this.button3.TabIndex = 20; + this.button3.Text = "Load bad"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // listBox4 + // + this.listBox4.FormattingEnabled = true; + this.listBox4.Location = new System.Drawing.Point(822, 166); + this.listBox4.Name = "listBox4"; + this.listBox4.Size = new System.Drawing.Size(154, 121); + this.listBox4.TabIndex = 21; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(822, 293); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(75, 21); + this.button4.TabIndex = 23; + this.button4.Text = "Load bad"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button5 + // + this.button5.Location = new System.Drawing.Point(901, 293); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(75, 21); + this.button5.TabIndex = 22; + this.button5.Text = "Save bad"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // checkBox4 + // + this.checkBox4.AutoSize = true; + this.checkBox4.Location = new System.Drawing.Point(932, 318); + this.checkBox4.Name = "checkBox4"; + this.checkBox4.Size = new System.Drawing.Size(38, 17); + this.checkBox4.TabIndex = 28; + this.checkBox4.Text = "Fill"; + this.checkBox4.UseVisualStyleBackColor = true; + this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(859, 318); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(54, 13); + this.label6.TabIndex = 27; + this.label6.Text = "Bad pix: 0"; + // + // checkBox5 + // + this.checkBox5.AutoSize = true; + this.checkBox5.Location = new System.Drawing.Point(496, 318); + this.checkBox5.Name = "checkBox5"; + this.checkBox5.Size = new System.Drawing.Size(45, 17); + this.checkBox5.TabIndex = 26; + this.checkBox5.Text = "Bad"; + this.checkBox5.UseVisualStyleBackColor = true; + this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(793, 318); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(56, 13); + this.label7.TabIndex = 25; + this.label7.Text = "Порог: 80"; + // + // trackBar3 + // + this.trackBar3.AutoSize = false; + this.trackBar3.Location = new System.Drawing.Point(547, 319); + this.trackBar3.Maximum = 255; + this.trackBar3.Name = "trackBar3"; + this.trackBar3.Size = new System.Drawing.Size(240, 23); + this.trackBar3.TabIndex = 24; + this.trackBar3.TickFrequency = 5; + this.trackBar3.Value = 80; + this.trackBar3.Scroll += new System.EventHandler(this.trackBar3_Scroll); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1002, 598); + this.Controls.Add(this.checkBox4); + this.Controls.Add(this.label6); + this.Controls.Add(this.checkBox5); + this.Controls.Add(this.label7); + this.Controls.Add(this.trackBar3); + this.Controls.Add(this.button4); + this.Controls.Add(this.button5); + this.Controls.Add(this.listBox4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button1); + this.Controls.Add(this.label5); + this.Controls.Add(this.trackBar2); + this.Controls.Add(this.checkBox3); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.checkBox2); + this.Controls.Add(this.label1); + this.Controls.Add(this.button2); + this.Controls.Add(this.listBox3); + this.Controls.Add(this.listBox2); + this.Controls.Add(this.pictureBox2); + this.Controls.Add(this.checkBox1); + this.Controls.Add(this.label2); + this.Controls.Add(this.trackBar1); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.pictureBox1); + this.Name = "Form1"; + this.Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TrackBar trackBar1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.ListBox listBox2; + private System.Windows.Forms.ListBox listBox3; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.CheckBox checkBox3; + private System.Windows.Forms.TrackBar trackBar2; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.ListBox listBox4; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.CheckBox checkBox4; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.CheckBox checkBox5; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TrackBar trackBar3; + } +} + diff --git a/test_image_processing_2/test_image_processing_2/Form1.cs b/test_image_processing_2/test_image_processing_2/Form1.cs new file mode 100644 index 0000000..101d30c --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Form1.cs @@ -0,0 +1,545 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.IO; + +namespace test_image_processing_2 +{ + public partial class Form1 : Form + { + public struct FIFO_ITEM + { + public ushort x; + public ushort y; + } + + //public struct BAD_PIX_FILE_STRUCTURE + //{ + // public ushort count; + // public fixed FIFO_ITEM array[256]; + //} + + unsafe public struct CONFIG_FILE_STRUCTURE + { + public fixed byte szSerialNumber[128];// matrix serial number, zero-terminated string + public ushort nXc, nYc; // centers of matrices, pix + public ushort nRs, nRb; // lens field of view radius ('s'=small, 'b'=big), pix + public byte cLc; // neighbour distance for clasters, pix + public ushort nLimit; // FIFO limit (10-bit) + public ushort nVinb, nVref; // VINB & VREF (10-bit) + public float fA, fB, fC; // Fi=A*x^2 + Bx + C + } + unsafe public struct THE_POINT + { + public FIFO_ITEM* pi; + public byte* pm; + } + public struct CLUSTER_COORD + { + public ushort count; // number of points (pixels) in cluster + public byte excluded; // flag, cluster should be ignored if TRUE + public byte marker; // cluster identicator + public ARM_RECT rect; // rectangular area of cluster (in pixels) + } + public struct ARM_RECT + { + public ushort left; + public ushort top; + public ushort right; + public ushort bottom; + } + unsafe void CopyRect(ARM_RECT* dst, ARM_RECT* src) + { + dst->left = src->left; + dst->top = src->top; + dst->right = src->right; + dst->bottom = src->bottom; + } + unsafe bool EmptyRect(ARM_RECT* r) + { + return !(((int)r->right - (int)r->left) > 0 && + ((int)r->bottom - (int)r->top) > 0); + } + unsafe bool IntersectRect(ARM_RECT* r, ARM_RECT* r1, ARM_RECT* r2) + { + ARM_RECT rect; + CopyRect(&rect, r1); + if (r2->left > r1->left) rect.left = r2->left; + if (r2->top > r1->top) rect.top = r2->top; + if (r2->right < r1->right) rect.right = r2->right; + if (r2->bottom < r1->bottom) rect.bottom = r2->bottom; + if (r != null) + *r = rect; + return !EmptyRect(&rect); + } + unsafe void make_point(FIFO_ITEM* pi, byte* pm, THE_POINT* point) + { + point->pi = pi; + point->pm = pm; + } + unsafe bool neighbour_points(THE_POINT* p1, THE_POINT* p2, byte length) + { + return (Math.Abs((short)p2->pi->x - (short)p1->pi->x) <= length) && + (Math.Abs((short)p2->pi->y - (short)p1->pi->y) <= length); + } + unsafe bool point_has_no_marker(THE_POINT* p) + { + return *(p->pm) == cnst.NO_MARKER; + } + unsafe void copy_marker(THE_POINT* dst, THE_POINT* src) + { + *(dst->pm) = *(src->pm); + } + public struct COORDS_DATA + { + uint time; // time of alarm, in 10us units + short angle1; // + short angle2; // + } + FolderBrowserDialog fld = new FolderBrowserDialog(); + String fold = ""; + int _mid = 0, _midb = 0; + Bitmap bm1, bm2; + public Form1() + { + InitializeComponent(); + } + + private void textBox1_DoubleClick(object sender, EventArgs e) + { + } + + void blacklines(ref Bitmap bb) + { + for (int i = 0; i < 320; i++) + { + bb.SetPixel(i, 0, Color.Black); + bb.SetPixel(i, 1, Color.Black); + } + for (int i = 0; i < 256; i++) + { + bb.SetPixel(0, i, Color.Black); + bb.SetPixel(1, i, Color.Black); + } + } + int[] midback(ref Bitmap bb) + { + int mid = 0, midb = 0; + int[] rez = new int[2]; + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bb.GetPixel(i, j); + mid += col.B; + } + for (int j = 0; j < 256; j++) + { + Color col = bb.GetPixel(i, j); + if (col.B < mid / 81920 + mid / 81920 / 100 * 5) + midb = (midb + col.B) / 2; + } + } + rez[0] = mid / 81920; + rez[1] = midb; + return rez; + } + private void listBox1_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBox1.Items.Count > 0) + { + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + int[] qq = midback(ref bm1); + label3.Text = "Среднее: " + qq[0].ToString() + " Средний фон: " + qq[1].ToString(); + _mid = qq[0]; + _midb = qq[1]; + pictureBox1.Image = bm1; + trackBar1.Minimum = qq[0] + 2; + } + } + private void listBox2_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBox2.Items.Count > 0) + { + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + int[] qq = midback(ref bm2); + label4.Text = "Среднее: " + qq[0].ToString() + " Средний фон: " + qq[1].ToString(); + pictureBox2.Image = bm2; + trackBar3.Minimum = qq[0] + 2; + } + } + + private void trackBar1_Scroll(object sender, EventArgs e) + { + label2.Text = "Порог: " + trackBar1.Value.ToString(); + if (listBox1.Items.Count > 0 && checkBox1.Checked) + { + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + if (bm1 != null) + { + listBox3.Items.Clear(); + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm1.GetPixel(i, j); + if (col.B > trackBar1.Value) + { + bm1.SetPixel(i, j, Color.Red); + listBox3.Items.Add(i + "\t" + j + "\t" + col.B); + if(checkBox2.Checked) + bm1.SetPixel(i, j, Color.Black); + } + } + } + pictureBox1.Image = bm1; + label1.Text = "Bad pix: " + listBox3.Items.Count.ToString(); + } + } + } + + private void button1_Click(object sender, EventArgs e) + { + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + if (listBox1.Items.Count > 0) + { + if (checkBox1.Checked) + { + listBox3.Items.Clear(); + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + if (bm1 != null) + { + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm1.GetPixel(i, j); + if (col.B > trackBar1.Value) + { + bm1.SetPixel(i, j, Color.Red); + listBox3.Items.Add(i + "\t" + j + "\t" + col.B); + if (checkBox2.Checked) + bm1.SetPixel(i, j, Color.Black); + } + } + } + pictureBox1.Image = bm1; + label1.Text = "Bad pix: " + listBox3.Items.Count.ToString(); + } + } + else + { + listBox3.Items.Clear(); + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + pictureBox1.Image = bm1; + label1.Text = "Bad pix: " + listBox3.Items.Count.ToString(); + } + } + } + + private void button2_Click(object sender, EventArgs e) + { + fld.SelectedPath = Application.StartupPath; + if (fld.ShowDialog() == DialogResult.OK) + { + fold = fld.SelectedPath; + textBox1.Text = fold + "\\"; + listBox1.Items.Clear(); + listBox1.Items.AddRange((new DirectoryInfo(fold)).GetFiles("*.bmp")); + if (listBox1.Items.Count > 0) + { + listBox1.SelectedIndex = 0; + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + pictureBox1.Image = bm1; + } + listBox2.Items.Clear(); + listBox2.Items.AddRange((new DirectoryInfo(fold)).GetFiles("*.bmp")); + if (listBox2.Items.Count > 0) + { + listBox2.SelectedIndex = 0; + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + pictureBox2.Image = bm2; + } + } + } + + private void checkBox2_CheckedChanged(object sender, EventArgs e) + { + if (listBox1.Items.Count > 0) + { + if (checkBox2.Checked) + { + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + if (bm1 != null) + { + for (int i = 0; i < listBox3.Items.Count; i++) + { + foreach (var item in listBox3.Items) + { + int x = Convert.ToInt32(item.ToString().Split(new Char[] { })[0]); + int y = Convert.ToInt32(item.ToString().Split(new Char[] { })[1]); + bm1.SetPixel(x, y, Color.Black); + } + } + pictureBox1.Image = bm1; + } + } + else + { + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + pictureBox1.Image = bm1; + } + } + } + + private void checkBox3_CheckedChanged(object sender, EventArgs e) + { +// bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); +// blacklines(ref bm1); +// bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); +// blacklines(ref bm2); + if (checkBox3.Checked) + { + if (bm1 != null) + { + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm1.GetPixel(i, j); + if (col.B <= trackBar2.Value) + { + bm1.SetPixel(i, j, Color.Black); + bm2.SetPixel(i, j, Color.Black); + } + } + } + } + } + pictureBox1.Image = bm1; + pictureBox2.Image = bm2; + } + private void trackBar2_Scroll(object sender, EventArgs e) + { + label5.Text = "Порог: " + trackBar2.Value.ToString(); +// bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); +// blacklines(ref bm1); +// bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); +// blacklines(ref bm2); + if (checkBox3.Checked) + { + if (bm1 != null) + { + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm1.GetPixel(i, j); + if (col.B <= trackBar2.Value) + { + bm1.SetPixel(i, j, Color.Black); + bm2.SetPixel(i, j, Color.Black); + } + } + } + } + } + pictureBox1.Image = bm1; + pictureBox2.Image = bm2; + } + + private void button1_Click_1(object sender, EventArgs e) + { + FileInfo fi = new FileInfo(fold + "\\" + listBox1.SelectedItem.ToString()); + using (StreamWriter wr = new StreamWriter((fold + "\\" + listBox1.SelectedItem.ToString()).Replace("bmp", "pix"), false)) + { + foreach (var item in listBox3.Items) + { + wr.WriteLine(item.ToString()); + } + } + } + private unsafe void button3_Click(object sender, EventArgs e) + { + try + { + using (StreamReader rd = new StreamReader((fold + "\\" + listBox1.SelectedItem.ToString()).Replace("bmp", "pix"))) + { + listBox3.Items.Clear(); + while (rd.Peek() >= 0) + listBox3.Items.Add(rd.ReadLine()); + } + } + catch (Exception) + { + MessageBox.Show("Файл битых пикселей не найден!"); + } + label1.Text = "Bad pix: " + listBox3.Items.Count.ToString(); + } + private void button5_Click(object sender, EventArgs e) + { + using (StreamWriter wr = new StreamWriter((fold + "\\" + listBox2.SelectedItem.ToString()).Replace("bmp", "pix"), false)) + { + foreach (var item in listBox4.Items) + { + wr.WriteLine(item.ToString()); + } + } + } + private void button4_Click(object sender, EventArgs e) + { + try + { + using (StreamReader rd = new StreamReader((fold + "\\" + listBox2.SelectedItem.ToString()).Replace("bmp", "pix"))) + { + listBox4.Items.Clear(); + while (rd.Peek() >= 0) + listBox4.Items.Add(rd.ReadLine()); + } + } + catch (Exception) + { + MessageBox.Show("Файл битых пикселей не найден!"); + } + label6.Text = "Bad pix: " + listBox4.Items.Count.ToString(); + } + private void trackBar3_Scroll(object sender, EventArgs e) + { + label7.Text = "Порог: " + trackBar3.Value.ToString(); + if (listBox2.Items.Count > 0 && checkBox5.Checked) + { + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + if (bm2 != null) + { + listBox4.Items.Clear(); + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm2.GetPixel(i, j); + if (col.B > trackBar3.Value) + { + listBox4.Items.Add(i + "\t" + j + "\t" + col.B); + if (checkBox4.Checked) + bm2.SetPixel(i, j, Color.Black); + else + bm2.SetPixel(i, j, Color.Red); + } + } + } + pictureBox2.Image = bm2; + label6.Text = "Bad pix: " + listBox4.Items.Count.ToString(); + } + } + } + + private void checkBox4_CheckedChanged(object sender, EventArgs e) + { + if (listBox2.Items.Count > 0) + { + if (checkBox4.Checked) + { + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + if (bm2 != null) + { + for (int i = 0; i < listBox4.Items.Count; i++) + { + foreach (var item in listBox4.Items) + { + int x = Convert.ToInt32(item.ToString().Split(new Char[] { })[0]); + int y = Convert.ToInt32(item.ToString().Split(new Char[] { })[1]); + bm2.SetPixel(x, y, Color.Black); + } + } + pictureBox2.Image = bm2; + } + } + else + { + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + pictureBox2.Image = bm2; + } + } + } + + private void checkBox5_CheckedChanged(object sender, EventArgs e) + { + if (listBox2.Items.Count > 0) + { + if (checkBox5.Checked) + { + listBox4.Items.Clear(); + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + if (bm2 != null) + { + for (int i = 0; i < 320; i++) + { + for (int j = 0; j < 256; j++) + { + Color col = bm2.GetPixel(i, j); + if (col.B > trackBar3.Value) + { + bm2.SetPixel(i, j, Color.Red); + listBox4.Items.Add(i + "\t" + j + "\t" + col.B); + if (checkBox4.Checked) + bm2.SetPixel(i, j, Color.Black); + } + } + } + pictureBox2.Image = bm2; + label6.Text = "Bad pix: " + listBox4.Items.Count.ToString(); + } + } + else + { + listBox3.Items.Clear(); + bm1 = (Bitmap)Image.FromFile(fold + "\\" + listBox1.SelectedItem.ToString()); + blacklines(ref bm1); + pictureBox1.Image = bm1; + bm2 = (Bitmap)Image.FromFile(fold + "\\" + listBox2.SelectedItem.ToString()); + blacklines(ref bm2); + pictureBox2.Image = bm2; + label1.Text = "Bad pix: " + listBox3.Items.Count.ToString(); + } + } + } + } + public class cnst + { + public const ushort BAD_PIXELS_ARRAY_SIZE = 256; + public const ushort SN_LENGTH = 128; + public const ushort NO_MARKER = 0; // 'no marker' cluster identifier + public const ushort REASON_BY_REQUEST = 0x0; // output status message initiated by host request + public const ushort REASON_BY_TIMER = 0x1; // output status message initiated by timer event + public const ushort REASON_BY_STATE = 0x2; // output status message initiated by state change + + public const ushort MODE_OPERATIONAL = 0x1; // normal mode + public const ushort MODE_PROGRAMMING = 0x2; // device is being programmed + } + public class BAD_PIX_FILE_STRUCTURE + { + + } + +} diff --git a/test_image_processing_2/test_image_processing_2/Form1.resx b/test_image_processing_2/test_image_processing_2/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/test_image_processing_2/test_image_processing_2/Program.cs b/test_image_processing_2/test_image_processing_2/Program.cs new file mode 100644 index 0000000..9bc34a5 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace test_image_processing_2 +{ + static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/test_image_processing_2/test_image_processing_2/Properties/AssemblyInfo.cs b/test_image_processing_2/test_image_processing_2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3cbd622 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Управление общими сведениями о сборке осуществляется с помощью +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("test_image_processing_2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("test_image_processing_2")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми +// для COM-компонентов. Если требуется обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("5eb8f01c-4d0a-4561-87df-efbc7c95c221")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/test_image_processing_2/test_image_processing_2/Properties/Resources.Designer.cs b/test_image_processing_2/test_image_processing_2/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4383b82 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace test_image_processing_2.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("test_image_processing_2.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/test_image_processing_2/test_image_processing_2/Properties/Resources.resx b/test_image_processing_2/test_image_processing_2/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/test_image_processing_2/test_image_processing_2/Properties/Settings.Designer.cs b/test_image_processing_2/test_image_processing_2/Properties/Settings.Designer.cs new file mode 100644 index 0000000..373d229 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace test_image_processing_2.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/test_image_processing_2/test_image_processing_2/Properties/Settings.settings b/test_image_processing_2/test_image_processing_2/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test_image_processing_2/test_image_processing_2/test_image_processing_2.csproj b/test_image_processing_2/test_image_processing_2/test_image_processing_2.csproj new file mode 100644 index 0000000..6bd931a --- /dev/null +++ b/test_image_processing_2/test_image_processing_2/test_image_processing_2.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {A7DB8256-E90B-45F5-913E-B9CF9138E509} + WinExe + Properties + test_image_processing_2 + test_image_processing_2 + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file