Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.55 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4.  
  5. #include <opencv2/core/core.hpp>
  6. #include <opencv2/highgui/highgui.hpp>
  7. #include "opencv2/imgproc/imgproc.hpp"
  8. #include <iostream>
  9.  
  10. using namespace cv;
  11. using namespace std;
  12.  
  13. //#define PH_SIZE 20000
  14.  
  15. #define PH_SIZE 600
  16.  
  17. #define IMAGE_X 640
  18. #define IMAGE_Y 480
  19.  
  20.  
  21. #define cfactorx 3
  22. #define radii 1
  23. #include "opencv2/highgui/highgui.hpp"
  24. #include <iostream>
  25.  
  26. using namespace cv;
  27. using namespace std;
  28. #include "opencv2/highgui/highgui.hpp"
  29. #include <iostream>
  30.  
  31. using namespace cv;
  32. using namespace std;
  33. double ty;
  34.  
  35.  
  36. int xh[] = { 197, 353, 469, 455, 512, 244, 463, 244, 381, 450, 448, 327, 237, 414, 378, 187, 542, 376, 298, 253, 392, 285, 300, 200, 546, 531, 244, 254, 223, 342, 264, 308, 313, 470, 183, 467, 484, 465, 185, 308, 337, 261, 280, 397, 532, 349, 394, 364, 260, 279, 254, 393, 450, 209, 169, 260, 491, 283, 248, 219, 269, 252, 283, 435, 329, 511, 394, 424, 337, 210, 328, 211, 351, 448, 330, 178, 248, 437, 529, 291, 295, 191, 432, 173, 444, 401, 197, 449, 193, 338, 232, 535, 531, 425, 489, 289, 236, 368, 379, 415, 172, 462, 317, 515, 202, 409, 523, 211, 218, 385, 428, 426, 398, 480, 180, 381, 489, 407, 209, 443, 232, 262, 291, 464, 439, 254, 416, 335, 316, 437, 443, 410, 403, 173, 541, 442, 484, 260, 485, 278, 447, 406, 558, 201, 256, 328, 164, 297, 423, 179, 246, 176, 267, 385, 176, 337, 219, 322, 254, 472, 338, 306, 354, 240, 468, 195, 462, 399, 497, 220, 177, 386, 479, 427, 313, 338, 277, 350, 381, 275, 348, 257, 344, 186, 340, 363, 324, 236, 196, 253, 259, 204, 546, 324, 402, 269, 454, 260, 190, 231, 343, 203, 449, 548, 454, 196, 311, 193, 490, 284, 246, 218, 187, 256, 175, 280, 180, 406, 468, 271, 188, 340, 420, 193, 375, 390, 461, 298, 241, 289, 288, 395, 258, 330, 226, 460, 368, 280, 338, 249, 364, 324, 259, 326, 199, 298, 504, 337, 319, 305, 278, 257, 357, 268, 294, 212, 364, 446, 287, 383, 331, 372, 234, 377, 322, 490, 229, 202, 173, 232, 243, 427, 371, 473, 468, 240, 376, 179, 407, 323, 220, 455, 519, 269, 384, 521, 342, 446, 443, 185, 333, 278, 541, 237, 405, 380, 303, 432, 185, 321, 415, 402, 419, 534, 288, 449, 305, 266, 197, 178, 211, 335, 203, 338, 210, 283, 386, 372, 317, 391, 464, 219, 274, 217, 457, 534, 172, 372, 364, 486, 256, 456, 222, 283, 262, 412, 306, 233, 413, 422, 399, 244, 409, 243, 285, 185, 305, 269, 184, 351, 274, 194, 365, 428, 479, 385, 245, 272, 425, 249, 439, 352, 544, 387, 197, 282, 519, 246, 243, 271, 419, 188, 440, 243, 365, 224, 316, 440, 330, 523, 339, 193, 317, 197, 359, 498, 296, 556, 277, 312, 306, 181, 327, 260, 203, 283, 475, 352, 357, 271, 258, 186, 431, 264, 350, 509, 521, 325, 345, 263, 385, 177, 473, 541, 462, 271, 355, 400, 502, 351, 439, 461, 353, 412, 461, 198, 295, 225, 401, 385, 271, 258, 198, 510, 329, 449, 502, 503, 541, 184, 174, 310, 341, 316, 208, 432, 255, 261, 334, 492, 422, 308, 287, 309, 188, 338, 528, 293, 396, 362, 254, 466, 439, 351, 422, 206, 443, 421, 202, 516, 382, 265, 372, 195, 531, 270, 235, 186, 454, 469, 298, 205, 425, 425, 335, 405, 311, 200, 314, 188, 500, 316, 530, 261, 279, 392, 188, 275, 192, 229, 229, 216, 191, 171, 199, 463, 368, 537, 403, 417, 211, 253, 223, 254, 220, 314, 423, 339, 360, 405, 338, 205, 431, 489, 480, 417, 304, 395, 421, 269, 419, 281, 421, 364, 332, 367, 372, 269, 362, 430, 480, 247, 484, 249, 430, 433, 559, 448, 451, 380, 216, 255, 319, 450, 442, 304, 351, 403, 468, 195, 450, 470, 541, 345, 315, 235, 344, 347, 459, 444, 252, 369, 209, 419, 530, 192, 241, 348, 225, 444, 243, 372, 280, 205, 475, 168, 241, 439, 298, 317, 452, 501, 358, 275, 499, 550, 525, 420, 234, 334, 183, 442, 386, 489, 510, 406, 397, 378, 550, 350, 511, 335, 221, 510, 321, 480, 440, 471, 276, 462, 389, 363, 415, 203, 416, 280, 320, 545, 493, 412, 199, 294, 403, 245, 517, 496, 368, 435, 480, 504, 372, 478, 435, 459, 303, 188, 354, 422, 230, 215 };
  37.  
  38. int yh[] = { 303, 334, 137, 103, 150, 18, 165, 454, 389, 79, 16, 129, 36, 149, 34, 160, 79, 339, 19, 24, 229, 300, 333, 398, 26, 36, 215, 352, 198, 324, 423, 242, 198, 142, 211, 183, 172, 121, 148, 26, 148, 104, 317, 40, 58, 130, 364, 68, 169, 406, 364, 368, 373, 252, 29, 162, 89, 313, 79, 134, 85, 413, 340, 297, 68, 187, 325, 211, 342, 390, 80, 169, 104, 359, 224, 215, 36, 72, 90, 378, 315, 335, 355, 46, 224, 337, 19, 261, 15, 140, 74, 192, 206, 360, 47, 101, 312, 278, 400, 188, 125, 333, 307, 211, 457, 28, 207, 424, 432, 210, 202, 215, 120, 247, 179, 383, 177, 29, 159, 311, 180, 19, 352, 282, 132, 370, 247, 245, 246, 241, 110, 307, 386, 154, 51, 211, 285, 190, 257, 137, 346, 172, 109, 348, 433, 424, 194, 185, 66, 400, 303, 453, 168, 171, 67, 87, 468, 402, 126, 189, 167, 290, 236, 356, 119, 436, 209, 92, 115, 98, 276, 162, 12, 269, 85, 404, 12, 134, 201, 272, 240, 55, 43, 444, 66, 218, 208, 224, 313, 370, 155, 225, 139, 155, 339, 443, 103, 217, 245, 357, 107, 188, 155, 54, 154, 58, 239, 395, 303, 273, 87, 152, 396, 84, 268, 462, 58, 51, 254, 281, 238, 413, 195, 456, 82, 167, 64, 195, 26, 145, 302, 279, 266, 178, 202, 208, 99, 300, 424, 144, 435, 19, 440, 344, 290, 89, 157, 259, 249, 418, 63, 430, 329, 68, 150, 167, 249, 300, 349, 42, 222, 174, 113, 336, 164, 148, 297, 296, 73, 273, 56, 223, 293, 303, 159, 18, 156, 388, 148, 324, 465, 234, 256, 382, 255, 152, 76, 345, 149, 439, 39, 334, 136, 113, 52, 288, 65, 342, 341, 28, 318, 244, 190, 63, 250, 43, 168, 340, 20, 343, 130, 2, 280, 320, 16, 146, 78, 116, 365, 396, 341, 322, 230, 224, 162, 97, 389, 42, 237, 7, 284, 131, 29, 114, 124, 354, 205, 9, 270, 377, 350, 316, 320, 6, 382, 182, 288, 201, 321, 223, 315, 224, 377, 60, 297, 48, 115, 357, 299, 51, 259, 341, 89, 91, 83, 351, 121, 226, 25, 247, 160, 344, 372, 196, 338, 70, 25, 35, 227, 29, 62, 83, 94, 152, 403, 18, 249, 162, 215, 373, 183, 450, 134, 150, 188, 13, 300, 346, 106, 158, 228, 305, 197, 56, 79, 66, 235, 216, 351, 405, 176, 199, 161, 221, 121, 42, 349, 74, 260, 273, 101, 322, 93, 53, 71, 373, 217, 412, 216, 34, 86, 320, 257, 50, 53, 144, 173, 93, 170, 49, 51, 228, 78, 71, 317, 243, 289, 364, 288, 211, 388, 229, 360, 250, 385, 284, 41, 143, 305, 108, 99, 117, 264, 23, 116, 261, 132, 94, 399, 97, 363, 440, 351, 236, 50, 406, 409, 88, 260, 69, 271, 228, 326, 65, 12, 207, 370, 352, 428, 238, 77, 150, 228, 236, 443, 237, 436, 64, 55, 169, 158, 314, 217, 355, 83, 299, 221, 166, 61, 320, 450, 475, 150, 208, 48, 40, 226, 178, 272, 221, 74, 126, 134, 81, 17, 285, 394, 397, 321, 108, 125, 74, 21, 268, 304, 428, 85, 395, 37, 173, 272, 325, 290, 413, 17, 255, 81, 66, 123, 294, 112, 298, 226, 90, 30, 52, 154, 375, 64, 275, 176, 315, 27, 257, 97, 285, 398, 157, 39, 49, 60, 21, 53, 228, 31, 78, 81, 421, 337, 124, 382, 279, 131, 118, 200, 200, 285, 22, 243, 109, 113, 198, 115, 223, 178, 183, 111, 64, 300, 387, 467, 253, 46, 211, 213, 285, 371, 208, 91, 199, 206, 303, 320, 133, 416, 207, 24, 61, 35, 278, 283, 299, 125, 231, 171, 151, 182, 178, 179, 162, 410, 278, 111, 145, 125, 98, 264, 342, 34, 239, 166, 32, 213, 252, 113, 143, 285, 35, 332, 427 };
  39. int rh[] = { 4, 9, 8, 5, 8, 2, 6, 8, 7, 6, 6, 4, 5, 4, 4, 3, 8, 8, 4, 5, 5, 3, 6, 8, 9, 8, 3, 6, 4, 4, 9, 4, 3, 5, 4, 8, 8, 8, 3, 3, 4, 3, 6, 3, 7, 4, 7, 4, 3, 8, 6, 8, 9, 3, 4, 3, 8, 6, 3, 3, 2, 7, 5, 7, 5, 8, 9, 4, 8, 7, 4, 4, 4, 9, 3, 4, 5, 4, 7, 8, 5, 4, 8, 4, 8, 7, 2, 9, 3, 4, 4, 8, 7, 7, 9, 4, 4, 5, 8, 6, 4, 8, 5, 8, 7, 3, 9, 9, 7, 7, 7, 4, 5, 7, 3, 8, 9, 5, 3, 8, 5, 4, 4, 9, 4, 6, 8, 3, 3, 8, 6, 8, 9, 3, 9, 5, 7, 5, 8, 4, 8, 6, 9, 5, 8, 8, 3, 3, 4, 8, 4, 8, 3, 5, 5, 4, 7, 8, 4, 8, 5, 3, 4, 5, 4, 9, 7, 5, 9, 3, 4, 4, 8, 8, 4, 9, 4, 4, 4, 4, 3, 3, 3, 8, 5, 4, 3, 4, 4, 6, 4, 3, 8, 4, 8, 9, 6, 4, 4, 5, 3, 2, 7, 9, 6, 4, 4, 9, 8, 3, 4, 4, 7, 5, 3, 8, 2, 5, 7, 4, 2, 8, 6, 8, 4, 5, 5, 5, 3, 4, 6, 5, 4, 4, 4, 8, 4, 5, 9, 3, 7, 3, 7, 4, 5, 2, 8, 5, 4, 8, 3, 8, 9, 3, 4, 3, 5, 9, 5, 4, 3, 3, 2, 9, 3, 7, 4, 4, 4, 4, 5, 6, 7, 7, 9, 2, 3, 7, 3, 5, 9, 8, 8, 8, 5, 8, 4, 8, 4, 9, 4, 6, 7, 2, 4, 5, 4, 8, 4, 4, 8, 5, 4, 9, 4, 6, 4, 6, 5, 6, 5, 4, 4, 7, 2, 4, 4, 5, 8, 9, 8, 4, 4, 4, 5, 7, 8, 3, 3, 7, 5, 4, 3, 5, 2, 8, 3, 5, 7, 8, 8, 4, 9, 3, 8, 3, 4, 5, 3, 4, 7, 2, 7, 7, 9, 5, 4, 5, 8, 4, 9, 6, 8, 4, 3, 4, 8, 4, 3, 4, 5, 4, 9, 4, 8, 4, 4, 5, 5, 7, 4, 3, 5, 5, 9, 7, 4, 8, 4, 9, 3, 7, 4, 2, 3, 3, 8, 7, 5, 4, 5, 3, 6, 3, 3, 8, 7, 4, 7, 9, 4, 4, 7, 8, 5, 4, 9, 5, 7, 6, 7, 9, 4, 4, 5, 5, 4, 9, 5, 4, 3, 3, 5, 8, 5, 6, 9, 8, 9, 4, 4, 5, 4, 2, 4, 5, 4, 5, 5, 8, 8, 3, 6, 5, 5, 7, 8, 4, 9, 3, 2, 6, 7, 4, 5, 4, 7, 5, 8, 8, 8, 7, 8, 5, 8, 8, 8, 3, 8, 6, 3, 3, 8, 4, 5, 4, 7, 6, 9, 4, 8, 5, 8, 5, 8, 5, 8, 3, 3, 4, 5, 4, 5, 5, 4, 9, 3, 7, 4, 8, 8, 9, 4, 2, 5, 4, 4, 4, 7, 7, 5, 5, 4, 9, 9, 8, 8, 9, 9, 5, 7, 4, 6, 6, 5, 7, 4, 8, 4, 7, 8, 4, 8, 9, 5, 8, 8, 4, 7, 6, 2, 4, 3, 5, 4, 2, 5, 7, 4, 5, 5, 7, 9, 5, 3, 4, 9, 4, 6, 4, 3, 3, 3, 6, 7, 3, 5, 7, 4, 6, 6, 5, 5, 2, 8, 4, 4, 6, 4, 3, 6, 8, 5, 4, 8, 8, 8, 5, 4, 7, 7, 8, 4, 8, 8, 9, 8, 5, 8, 4, 9, 4, 4, 7, 7, 7, 6, 6, 4, 7, 5, 6, 5, 4, 5, 3, 4, 8, 7, 4, 8, 4, 4, 2, 8, 8, 5, 8, 9, 8, 5, 8, 5, 8, 4, 3, 4, 4, 4, 7 };
  40.  
  41.  
  42. void CallBackFunc(int event, int x, int y, int flags, void* userdata)
  43. {
  44. if (event == EVENT_LBUTTONDOWN)
  45. {
  46. //cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
  47. ty = y;
  48. }
  49. else if (event == EVENT_RBUTTONDOWN)
  50. {
  51. //cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
  52. ty = y;
  53. }
  54. else if (event == EVENT_MBUTTONDOWN)
  55. {
  56. //cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
  57. ty = y;
  58. }
  59. else if (event == EVENT_MOUSEMOVE)
  60. {
  61. //cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;
  62. ty = y;
  63. }
  64. printf("%d\n", y);
  65. }
  66. /*int main(int argc, char* argv[])
  67. {
  68. VideoCapture cap(0); // open the video camera no. 0
  69.  
  70. if (!cap.isOpened()) // if not success, exit program
  71. {
  72. cout << "Cannot open the video cam" << endl;
  73. return -1;
  74. }
  75.  
  76. double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
  77. double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  78.  
  79. cout << "Frame size : " << dWidth << " x " << dHeight << endl;
  80.  
  81. namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
  82.  
  83. while (1)
  84. {
  85. Mat frame;
  86.  
  87. bool bSuccess = cap.read(frame); // read a new frame from video
  88.  
  89. if (!bSuccess) //if not success, break loop
  90. {
  91. cout << "Cannot read a frame from video stream" << endl;
  92. break;
  93. }
  94.  
  95. imshow("MyVideo", frame); //show the frame in "MyVideo" window
  96.  
  97. if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
  98. {
  99. cout << "esc key is pressed by user" << endl;
  100. break;
  101. }
  102. }
  103. return 0;
  104.  
  105. }*/
  106.  
  107.  
  108. int main(int argc, char** argv)
  109. {
  110.  
  111. //Camera stuff
  112. VideoCapture cap(0); // open the video camera no. 0
  113.  
  114. if (!cap.isOpened()) // if not success, exit program
  115. {
  116. cout << "Cannot open the video cam" << endl;
  117. return -1;
  118. }
  119. //Camera stuff
  120.  
  121. double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
  122. double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  123.  
  124. cout << "Frame size : " << dWidth << " x " << dHeight << endl;
  125.  
  126.  
  127.  
  128. Point phsexamine[PH_SIZE];
  129. Point phsdisplay[PH_SIZE];
  130. int r[PH_SIZE];
  131. int gray[PH_SIZE];
  132.  
  133. for (int i = 0; i < PH_SIZE; i++){
  134. int x, y;
  135. if (xh[i]>IMAGE_X){
  136. x = IMAGE_X;
  137. }
  138. else{
  139. x = xh[i];
  140. }
  141. if (yh[i]>IMAGE_Y){
  142. y = IMAGE_Y;
  143. }
  144. else{
  145. y = yh[i];
  146. }
  147. //phsdisplay[i] = Point(rand() % 640, rand() % 480);
  148. phsdisplay[i] = Point(x, y);
  149. r[i] = rh[i];
  150. //r[i] = rand() % radii + 3;
  151.  
  152. //printf("random phosphane: x=%d, y=%d, r=%d\n", (int) phsdisplay[i].x , (int) phsdisplay[i].y, r[i]);
  153. }
  154. /*
  155. int rexamine[PH_SIZE];
  156. for (int i = 0; i < PH_SIZE; i++){
  157. rexamine[i] = r[i];
  158. }
  159.  
  160.  
  161.  
  162. //const int m_length = sizeof(phsdisplay) / sizeof(Point);
  163.  
  164. //printf("size: %d\n", m_length);
  165.  
  166. for (int i = 0; i < PH_SIZE; i++){
  167. phsexamine[i].x = 320-320/zoom+phsdisplay[i].x*cfactorx/zoom;
  168. phsexamine[i].y = 480-480/zoom+phsdisplay[i].y/zoom;
  169. }*/
  170.  
  171. //Mat image;
  172. //image = imread("p.jpg", IMREAD_GRAYSCALE); //default size: 640x480
  173. //if (!image.data) // Check for invalid input
  174. //{
  175. // cout << "Could not open or find the image" << std::endl;
  176. // return -1;
  177. //}
  178.  
  179.  
  180.  
  181. while (1)
  182. {
  183.  
  184.  
  185.  
  186.  
  187. double zoom = (100 + 200*ty / 480)/100;
  188.  
  189.  
  190. int rexamine[PH_SIZE];
  191. for (int i = 0; i < PH_SIZE; i++){
  192. rexamine[i] = r[i]/zoom;
  193. }
  194.  
  195.  
  196.  
  197. //const int m_length = sizeof(phsdisplay) / sizeof(Point);
  198.  
  199. //printf("size: %d\n", m_length);
  200.  
  201. for (int i = 0; i < PH_SIZE; i++){
  202. phsexamine[i].x = 320 - 320 / zoom + phsdisplay[i].x*cfactorx / zoom;
  203. phsexamine[i].y = 480 - 480 / zoom + phsdisplay[i].y / zoom;
  204. }
  205. //Camera
  206. Mat image;
  207. Mat PhosOnly;
  208.  
  209. bool bSuccess = cap.read(image); // read a new frame from video
  210. bSuccess = cap.read(PhosOnly); // read a new frame from video
  211.  
  212.  
  213. PhosOnly = cv::Scalar(0, 0, 0);
  214. // CvSet(PhosOnly, CV_RGB(0, 0, 0));
  215.  
  216.  
  217. if (!bSuccess) //if not success, break loop
  218. {
  219. cout << "Cannot read a frame from video stream" << endl;
  220. //break;
  221. }
  222. //circle(PhosOnly, Junk[0], 240, Scalar(255,255,255),1,8,0); //circle at the center
  223.  
  224. //resize(image, image2, Size((int)round(zoom*640), (int)round(zoom*480)));
  225. //printf("%d, %d\n", (int)round(zoom * 640), (int)round(zoom * 480));
  226.  
  227. //draw phosphane circle
  228. for (int i = 0; i < PH_SIZE; i++){
  229. circle(image, phsdisplay[i], r[i], Scalar(255, 255, 255), 1); //circle at the center
  230. }
  231.  
  232.  
  233.  
  234. for (int i = 0; i < PH_SIZE; i++){
  235.  
  236. int tval = 0;
  237. int countxy = 0;
  238.  
  239. int left = phsexamine[i].x - rexamine[i];
  240. if (left < 0){
  241. left = 0;
  242. }
  243.  
  244. int right = phsexamine[i].x + rexamine[i];
  245. if (right>639*cfactorx){
  246. right = 639*cfactorx;
  247. }
  248.  
  249. int top = phsexamine[i].y - rexamine[i];
  250. if (top<0){
  251. top = 0;
  252. }
  253.  
  254. int bottom = phsexamine[i].y + rexamine[i];
  255. if (bottom > 479){
  256. bottom = 479;
  257. }
  258.  
  259.  
  260. //begins search for phosphane --
  261. for (int yco = top; yco <= bottom; yco++){
  262. for (int xco = left; xco <= right; xco++){
  263. if (pow(yco - phsexamine[i].y, 2) + pow(xco - phsexamine[i].x, 2) < pow(rexamine[i], 2)){
  264. countxy = countxy + 1;
  265. tval = tval + image.at<uchar>(phsexamine[i].y, phsexamine[i].x);
  266. }
  267. }
  268. }
  269.  
  270. if (countxy == 0){
  271. tval = tval;
  272. if (gray[i] > 254){
  273. gray[i] = 0;
  274. }
  275. }
  276. else{
  277.  
  278. gray[i] = tval / (countxy);
  279. //if (gray[i] > 255){
  280. //gray[i] =0;
  281. //}
  282. }
  283. //printf("x=%d, y=%d, gray=%d, tval=%d, countxt=%d\n, top=%d, bottom=%d, left=%d, right=%d\n", phsexamine[i].x, phsexamine[i].y, gray[i], tval, countxy, top, bottom, left, right);
  284.  
  285.  
  286. }
  287.  
  288. //for (int i = 0; i < PH_SIZE; i++){
  289. //gray[i] = image.at<uchar>(phsexamine[i].y, phsexamine[i].x);
  290. //}
  291.  
  292. for (int i = 0; i < PH_SIZE; i++){
  293. //circle(image, phsdisplay[i], r[i], Scalar(gray[i], gray[i], gray[i]), -1); //circle at the center
  294. circle(PhosOnly, phsdisplay[i], r[i], Scalar(gray[i], gray[i], gray[i]), -1); //circle at the center
  295. }
  296.  
  297. namedWindow("original", WINDOW_AUTOSIZE); // Create a window for display.
  298. imshow("original", image); // Show our image inside it.
  299.  
  300. namedWindow("PhosOnly", WINDOW_NORMAL); // Create a window for display.
  301. imshow("PhosOnly", PhosOnly); // Show our image inside it.
  302. setWindowProperty("PhosOnly", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
  303. setMouseCallback("PhosOnly", CallBackFunc, NULL);
  304.  
  305.  
  306. if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
  307. {
  308. cout << "esc key is pressed by user" << endl;
  309. break;
  310. }
  311. }//wend
  312. //waitKey(0); // Wait for a keystroke in the window
  313. cap.release();
  314. return 0;
  315.  
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement