Frame No | Meteor No | Path | Frame No In File | Date | Time | Detection pix rate | x avr. | y avr. | x sigma | y sigma | x min | y min | x max | y maxin |
0001 | 0001 | ./2176x2176_230813_211934_616730.ser | 0121 | 2023-08-13 | 12:20:31.912060UTC | 0.0015% | 1194 | 1814 | 5 | 4 | 1182 | 1807 | 1202 | 1820 |
0002 | 0001 | ./2176x2176_230813_211934_616730.ser | 0122 | 2023-08-13 | 12:20:32.417774UTC | 0.0028% | 1221 | 1831 | 13 | 7 | 1202 | 1819 | 1254 | 1848 |
0003 | 0002 | ./2176x2176_230813_215637_448856.ser | 0112 | 2023-08-13 | 12:57:35.770398UTC | 0.0188% | 662 | 1249 | 28 | 43 | 609 | 1163 | 710 | 1321 |
0004 | 0002 | ./2176x2176_230813_215637_448856.ser | 0113 | 2023-08-13 | 12:57:36.138127UTC | 0.0273% | 777 | 1410 | 40 | 52 | 708 | 1319 | 851 | 1500 |
0005 | 0003 | ./2176x2176_230813_220644_721094.ser | 0038 | 2023-08-13 | 13:07:02.747051UTC | 0.0051% | 1911 | 1396 | 11 | 17 | 1890 | 1366 | 1928 | 1425 |
0006 | 0003 | ./2176x2176_230813_220644_721094.ser | 0039 | 2023-08-13 | 13:07:03.185460UTC | 0.0044% | 1940 | 1446 | 7 | 13 | 1927 | 1423 | 1951 | 1468 |
0007 | 0004 | ./2176x2176_230813_221745_030835.ser | 0063 | 2023-08-13 | 13:18:21.15068UTC | 0.0056% | 1312 | 1515 | 27 | 22 | 1256 | 1469 | 1352 | 1547 |
0008 | 0004 | ./2176x2176_230813_221745_030835.ser | 0064 | 2023-08-13 | 13:18:21.533953UTC | 0.0116% | 1417 | 1598 | 38 | 29 | 1352 | 1547 | 1488 | 1652 |
0009 | 0005 | ./2176x2176_230813_221745_030835.ser | 0090 | 2023-08-13 | 13:18:33.851868UTC | 0.0016% | 2009 | 790 | 5 | 6 | 2001 | 778 | 2017 | 800 |
0010 | 0006 | ./2176x2176_230813_223149_940304.ser | 0067 | 2023-08-13 | 13:32:30.664567UTC | 0.0039% | 1192 | 852 | 20 | 13 | 1139 | 819 | 1222 | 872 |
0011 | 0006 | ./2176x2176_230813_223149_940304.ser | 0068 | 2023-08-13 | 13:32:31.191807UTC | 0.0196% | 1316 | 936 | 48 | 33 | 1224 | 872 | 1406 | 1000 |
0012 | 0007 | ./2176x2176_230813_223450_285888.ser | 0053 | 2023-08-13 | 13:35:15.447331UTC | 0.0020% | 884 | 245 | 11 | 3 | 862 | 240 | 902 | 250 |
0013 | 0008 | ./2176x2176_230813_224610_016091.ser | 0086 | 2023-08-13 | 13:46:50.721269UTC | 0.0030% | 1064 | 1686 | 10 | 1 | 1046 | 1683 | 1081 | 1689 |
0014 | 0009 | ./2176x2176_230813_224917_303904.ser | 0021 | 2023-08-13 | 13:49:26.976365UTC | 0.0026% | 966 | 1126 | 12 | 12 | 937 | 1098 | 985 | 1144 |
0015 | 0009 | ./2176x2176_230813_224917_303904.ser | 0022 | 2023-08-13 | 13:49:27.399878UTC | 0.0271% | 1082 | 1232 | 49 | 44 | 986 | 1144 | 1162 | 1304 |
0016 | 0009 | ./2176x2176_230813_224917_303904.ser | 0023 | 2023-08-13 | 13:49:28.29901UTC | 0.0039% | 1173 | 1313 | 7 | 6 | 1160 | 1301 | 1189 | 1326 |
0017 | 0010 | ./2176x2176_230813_224917_303904.ser | 0028 | 2023-08-13 | 13:49:30.232413UTC | 0.0022% | 563 | 607 | 7 | 4 | 551 | 599 | 575 | 613 |
0018 | 0011 | ./2176x2176_230813_233213_421381.ser | 0047 | 2023-08-13 | 14:32:35.620768UTC | 0.0014% | 530 | 758 | 3 | 5 | 524 | 747 | 536 | 766 |
0019 | 0011 | ./2176x2176_230813_233213_421381.ser | 0048 | 2023-08-13 | 14:32:36.143866UTC | 0.0043% | 548 | 784 | 7 | 10 | 535 | 766 | 561 | 802 |
0020 | 0012 | ./2176x2176_230814_000519_032429.ser | 0037 | 2023-08-13 | 15:05:36.552570UTC | 0.0054% | 260 | 671 | 6 | 3 | 248 | 664 | 273 | 678 |
0021 | 0013 | ./2176x2176_230814_000619_156488.ser | 0073 | 2023-08-13 | 15:06:53.706239UTC | 0.0098% | 1469 | 801 | 39 | 14 | 1375 | 768 | 1525 | 823 |
0022 | 0013 | ./2176x2176_230814_000619_156488.ser | 0074 | 2023-08-13 | 15:06:54.187536UTC | 0.0045% | 1547 | 831 | 12 | 6 | 1525 | 821 | 1572 | 842 |
0023 | 0014 | ./2176x2176_230814_000719_659948.ser | 0103 | 2023-08-13 | 15:08:15.175133UTC | 0.0030% | 1888 | 1078 | 15 | 12 | 1860 | 1058 | 1916 | 1101 |
0024 | 0015 | ./2176x2176_230814_000819_440829.ser | 0046 | 2023-08-13 | 15:08:41.156424UTC | 0.0040% | 1178 | 1890 | 14 | 9 | 1148 | 1870 | 1200 | 1905 |
0025 | 0015 | ./2176x2176_230814_000819_440829.ser | 0047 | 2023-08-13 | 15:08:41.691351UTC | 0.0050% | 1225 | 1920 | 14 | 9 | 1199 | 1904 | 1247 | 1934 |
0026 | 0016 | ./2176x2176_230814_002127_484953.ser | 0057 | 2023-08-13 | 15:21:54.513382UTC | 0.0023% | 1650 | 1863 | 11 | 3 | 1626 | 1856 | 1668 | 1868 |
0027 | 0017 | ./2176x2176_230814_004134_504531.ser | 0001 | 2023-08-13 | 15:41:35.46634UTC | 0.0050% | 1295 | 233 | 8 | 2 | 1281 | 229 | 1314 | 237 |
0028 | 0018 | ./2176x2176_230814_004934_951193.ser | 0020 | 2023-08-13 | 15:49:44.434356UTC | 0.0005% | 882 | 811 | 5 | 2 | 873 | 808 | 891 | 815 |
0029 | 0019 | ./2176x2176_230814_004934_951193.ser | 0049 | 2023-08-13 | 15:49:58.663188UTC | 0.0022% | 417 | 1124 | 1 | 9 | 415 | 1104 | 419 | 1138 |
0030 | 0019 | ./2176x2176_230814_004934_951193.ser | 0050 | 2023-08-13 | 15:49:59.92860UTC | 0.0047% | 418 | 1163 | 2 | 13 | 415 | 1139 | 422 | 1184 |
0031 | 0020 | ./2176x2176_230814_005334_933494.ser | 0076 | 2023-08-13 | 15:54:12.877761UTC | 0.0018% | 1129 | 1318 | 7 | 6 | 1117 | 1308 | 1142 | 1331 |
0032 | 0020 | ./2176x2176_230814_005334_933494.ser | 0077 | 2023-08-13 | 15:54:13.288725UTC | 0.0109% | 1192 | 1371 | 24 | 20 | 1147 | 1333 | 1240 | 1408 |
0033 | 0021 | ./2176x2176_230814_011536_019767.ser | 0109 | 2023-08-13 | 16:16:32.356214UTC | 0.0023% | 954 | 103 | 6 | 4 | 942 | 96 | 965 | 111 |
0034 | 0022 | ./2176x2176_230814_011636_191545.ser | 0112 | 2023-08-13 | 16:17:33.415175UTC | 0.0022% | 477 | 537 | 2 | 6 | 473 | 527 | 480 | 548 |
0035 | 0023 | ./2176x2176_230814_012136_226146.ser | 0011 | 2023-08-13 | 16:21:41.443640UTC | 0.0052% | 762 | 1648 | 63 | 64 | 698 | 1608 | 892 | 1784 |
0036 | 0024 | ./2176x2176_230814_014037_501893.ser | 0071 | 2023-08-13 | 16:41:11.72791UTC | 0.0023% | 578 | 303 | 2 | 5 | 575 | 293 | 582 | 314 |
0037 | 0024 | ./2176x2176_230814_014037_501893.ser | 0072 | 2023-08-13 | 16:41:11.589103UTC | 0.0079% | 587 | 274 | 4 | 10 | 579 | 257 | 596 | 295 |
0038 | 0025 | ./2176x2176_230814_014937_012397.ser | 0098 | 2023-08-13 | 16:50:24.444588UTC | 0.0027% | 1443 | 1888 | 9 | 6 | 1424 | 1875 | 1457 | 1897 |
0039 | 0026 | ./2176x2176_230814_022039_208872.ser | 0103 | 2023-08-13 | 17:21:27.947090UTC | 0.0083% | 812 | 335 | 11 | 15 | 791 | 306 | 832 | 366 |
0040 | 0027 | ./2176x2176_230814_022239_413480.ser | 0046 | 2023-08-13 | 17:23:01.193184UTC | 0.0083% | 1052 | 672 | 22 | 3 | 1004 | 666 | 1094 | 678 |
0041 | 0028 | ./2176x2176_230814_023139_975004.ser | 0055 | 2023-08-13 | 17:32:06.75529UTC | 0.0019% | 288 | 778 | 6 | 2 | 278 | 775 | 302 | 781 |
0042 | 0029 | ./2176x2176_230814_023440_382094.ser | 0021 | 2023-08-13 | 17:34:50.262129UTC | 0.0103% | 783 | 1401 | 9 | 25 | 765 | 1349 | 800 | 1440 |
0043 | 0029 | ./2176x2176_230814_023440_382094.ser | 0022 | 2023-08-13 | 17:34:50.798696UTC | 0.0120% | 816 | 1482 | 11 | 26 | 796 | 1438 | 839 | 1532 |
0044 | 0030 | ./2176x2176_230814_024141_189535.ser | 0016 | 2023-08-13 | 17:41:48.706278UTC | 0.0034% | 681 | 1748 | 3 | 8 | 674 | 1731 | 688 | 1762 |
0045 | 0031 | ./2176x2176_230814_024141_189535.ser | 0043 | 2023-08-13 | 17:42:01.546529UTC | 0.0009% | 570 | 1161 | 7 | 6 | 552 | 1148 | 582 | 1171 |
0046 | 0032 | ./2176x2176_230814_024340_944089.ser | 0040 | 2023-08-13 | 17:43:59.873203UTC | 0.0025% | 1040 | 1960 | 8 | 10 | 1024 | 1942 | 1057 | 1979 |
0047 | 0033 | ./2176x2176_230814_024641_214383.ser | 0062 | 2023-08-13 | 17:47:10.627026UTC | 0.0021% | 318 | 1688 | 2 | 5 | 314 | 1677 | 321 | 1696 |
0048 | 0033 | ./2176x2176_230814_024641_214383.ser | 0063 | 2023-08-13 | 17:47:11.51222UTC | 0.0083% | 322 | 1717 | 3 | 13 | 314 | 1695 | 329 | 1741 |
0049 | 0034 | ./2176x2176_230814_025541_298370.ser | 0019 | 2023-08-13 | 17:55:50.357926UTC | 0.0044% | 1059 | 1945 | 12 | 16 | 1034 | 1910 | 1088 | 1982 |
0050 | 0035 | ./2176x2176_230814_025741_528020.ser | 0103 | 2023-08-13 | 17:58:30.285406UTC | 0.0033% | 516 | 772 | 6 | 2 | 504 | 769 | 529 | 776 |
0051 | 0036 | ./2176x2176_230814_030141_980739.ser | 0067 | 2023-08-13 | 18:02:13.722720UTC | 0.0005% | 1497 | 487 | 15 | 1 | 1478 | 485 | 1522 | 488 |
0052 | 0037 | ./2176x2176_230814_030542_438484.ser | 0048 | 2023-08-13 | 18:06:05.166190UTC | 0.0045% | 1553 | 530 | 16 | 1 | 1524 | 527 | 1583 | 532 |
0053 | 0038 | ./2176x2176_230814_030642_559976.ser | 0008 | 2023-08-13 | 18:06:46.375014UTC | 0.0014% | 845 | 1258 | 3 | 6 | 840 | 1248 | 850 | 1269 |
0054 | 0039 | ./2176x2176_230814_031242_787598.ser | 0019 | 2023-08-13 | 18:12:51.765136UTC | 0.0017% | 925 | 1995 | 5 | 6 | 917 | 1986 | 935 | 2006 |
0055 | 0040 | ./2176x2176_230814_031742_867072.ser | 0043 | 2023-08-13 | 18:18:03.221385UTC | 0.0034% | 457 | 720 | 7 | 3 | 444 | 715 | 471 | 725 |
0056 | 0041 | ./2176x2176_230814_031742_867072.ser | 0124 | 2023-08-13 | 18:18:41.560519UTC | 0.0017% | 623 | 1066 | 2 | 7 | 619 | 1053 | 628 | 1078 |
0057 | 0042 | ./2176x2176_230814_032343_546878.ser | 0033 | 2023-08-13 | 18:23:59.223849UTC | 0.0017% | 224 | 1184 | 4 | 5 | 216 | 1174 | 232 | 1194 |
0058 | 0043 | ./2176x2176_230814_032443_192625.ser | 0112 | 2023-08-13 | 18:25:36.281829UTC | 0.0012% | 1202 | 1746 | 5 | 7 | 1194 | 1734 | 1211 | 1758 |
0059 | 0044 | ./2176x2176_230814_032743_575557.ser | 0125 | 2023-08-13 | 18:28:42.770509UTC | 0.0035% | 1903 | 1605 | 8 | 8 | 1887 | 1590 | 1915 | 1618 |
0060 | 0045 | ./2176x2176_230814_033143_576866.ser | 0007 | 2023-08-13 | 18:31:46.842669UTC | 0.0075% | 417 | 452 | 9 | 7 | 401 | 438 | 436 | 467 |
0061 | 0046 | ./2176x2176_230814_033243_692050.ser | 0101 | 2023-08-13 | 18:33:31.449127UTC | 0.0059% | 677 | 1953 | 5 | 12 | 667 | 1930 | 688 | 1973 |
0062 | 0047 | ./2176x2176_230814_033943_953764.ser | 0041 | 2023-08-13 | 18:40:03.368984UTC | 0.0015% | 1004 | 1313 | 558 | 488 | 605 | 619 | 1795 | 1662 |
0063 | 0048 | ./2176x2176_230814_033943_953764.ser | 0050 | 2023-08-13 | 18:40:07.692657UTC | 0.0014% | 1057 | 1272 | 625 | 458 | 558 | 690 | 1847 | 1639 |
画像処理関数
RAWで処理する関数を作成しました。
14個から20個に増えました。
void InitImage(unsigned short *dst, int width, int height, unsigned short val);
void SLImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void SDImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void AvrImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void SubImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void DifImage(unsigned short *dst, unsigned short *src1, unsigned short *src2, int width, int height, int num);
void AbsImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void CopyImage(unsigned short *dst, unsigned short *src, int width, int height, int num);
void BNRImage(unsigned short *dst, unsigned short threshold, int width, int height, int masksize);
void BNRImageArea(unsigned short *dst, unsigned short threshold, int width, int height, int masksize, int *minx, int *miny, int *maxx, int *maxy);
float BinzImage(unsigned short *dst, unsigned short threshold, int width, int height);
void BinzImageArea(unsigned short *dst, unsigned short threshold, int width, int height, int *minx, int *miny, int *maxx, int *maxy);
float CountImage(unsigned short *dst, unsigned short threshold, int width, int height);
void SDeviImage(unsigned short *dst, unsigned short threshold, int width, int height, double *ax, double *ay, double *sx, double *sy);
void MaxMinImage(unsigned short *dst, unsigned short threshold, int width, int height, int *minx, int *miny, int *maxx, int *maxy);
void SDeviMaxImage(unsigned short *dst, unsigned short threshold, int width, int height, double *ax, double *ay, double *sx, double *sy, int *minx, int *miny, int *maxx, int *maxy);
void SDeviMaxImageArea(unsigned short *dst, unsigned short threshold, int width, int height, double *ax, double *ay, double *sx, double *sy, int *minx, int *miny, int *maxx, int *maxy);
void NRImage(unsigned short *dst, unsigned short threshold, int width, int height);
void WBImageRG(unsigned short *src, int width, int height);
bool GetPix(unsigned short *dst, unsigned short threshold, int width, int height, int x, int y);
バッチ版(meteordetector11)ソース
赤字が前回との差分です。
int readSer(char *path, float lthresh, float ratio, double sthresh, unsigned short bthresh){
FILE *fpSer;
serHeader SerHeader;
char tmpc[41];
printf("%s\n",path);
fpSer = fopen64(path, "rb");
int r = fread(&SerHeader.FileID, 1, sizeof(SerHeader.FileID), fpSer);
strncpy(tmpc, SerHeader.FileID, 14);
tmpc[14]='\0';
r = fread(&SerHeader.LuID, 1, sizeof(SerHeader.LuID), fpSer);
r = fread(&SerHeader.ColorID, 1, sizeof(SerHeader.ColorID), fpSer);
r = fread(&SerHeader.LittleEndian, 1, sizeof(SerHeader.LittleEndian), fpSer);
r = fread(&SerHeader.ImageWidth, 1, sizeof(SEEK_CUR), fpSer);
r = fread(&SerHeader.ImageHeight, 1, sizeof(SerHeader.ImageHeight), fpSer);
r = fread(&SerHeader.PixelDepthPerPlane, 1, sizeof(SerHeader.PixelDepthPerPlane), fpSer);
r = fread(&SerHeader.FrameCount, 1, sizeof(SerHeader.FrameCount), fpSer);
r = fread(&SerHeader.Observer, 1, sizeof(SerHeader.Observer), fpSer);
strncpy(tmpc, SerHeader.Observer, 40);
tmpc[40]='\0';
r = fread(&SerHeader.Instrument, 1, sizeof(SerHeader.Instrument), fpSer);
strncpy(tmpc, SerHeader.Instrument, 40);
tmpc[40]='\0';
r = fread(&SerHeader.Telescope, 1, sizeof(SerHeader.Telescope), fpSer);
strncpy(tmpc, SerHeader.Telescope, 40);
tmpc[40]='\0';//
int year, month, day, hour, minute, second, microsec;
r = fread(&SerHeader.DateTime, 1, sizeof(SerHeader.DateTime), fpSer);
timestamp2date(SerHeader.DateTime, &year, &month, &day, &hour, &minute, &second, µsec);
r = fread(&SerHeader.DateTime_UTC, 1, sizeof(SerHeader.DateTime_UTC), fpSer);
timestamp2date(SerHeader.DateTime_UTC, &year, &month, &day, &hour, &minute, &second, µsec);
unsigned long TrailerDate;
unsigned long *TrailerDateP = (unsigned long *)malloc(SerHeader.FrameCount * sizeof(TrailerDate));
fseek(fpSer, -1*SerHeader.FrameCount * sizeof(TrailerDate), SEEK_END);
for(int i = 0; i < SerHeader.FrameCount; i++){
r = fread(&TrailerDate, 1, sizeof(TrailerDate), fpSer);
if(r < 1){
printf("trailer read error\n");
free(TrailerDateP);
return(1);
}
TrailerDateP[i] = TrailerDate;
timestamp2date(TrailerDate, &year, &month, &day, &hour, &minute, &second, µsec);
}
fseek(fpSer, 178, SEEK_SET);
int RawSize = SerHeader.ImageWidth * SerHeader.ImageHeight * SerHeader.PixelDepthPerPlane / 8;
cv::Mat rgb8BitMat(SerHeader.ImageHeight, SerHeader.ImageWidth, CV_8UC3); // RGB用バッファを用意
cv::Mat rgb8BitMat2(SerHeader.ImageHeight/2, SerHeader.ImageWidth/2, CV_8UC3); // RGB用バッファを用意
int oc = -1;
for(int i=0; i<SerHeader.FrameCount; i++){
Temp = OldImage;
OldImage = NewImage;
NewImage = Temp;
int r = fread(NewImage, sizeof(char), RawSize, fpSer);
if(r < RawSize){
printf("image read error\n");
break;
}
if(DarkImage != NULL)
SubImage(NewImage, DarkImage, SerHeader.ImageWidth, SerHeader.ImageHeight, 0);
WBImageRG((unsigned short *)NewImage, SerHeader.ImageWidth, SerHeader.ImageWidth);
if(mask_r.data != NULL)
bmask(mask_r, (unsigned short *)NewImage);
if(i == 0)//
continue;
DifImage(DffImage, NewImage, OldImage, SerHeader.ImageWidth, SerHeader.ImageHeight, 0);
NRImage(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight);
if(mask_d.data != NULL)
bmask(mask_d, DffImage);
float lrate = BinzImage(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight) * 100;
if(lrate < 0.03 && lrate > lthresh){
double ax, ay, sx, sy;
int minx, miny, maxx, maxy;
SDeviMaxImage(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight, &ax, &ay, &sx, &sy, &minx, &miny, &maxx, &maxy);
if(!GetPix(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight, (minx + maxx) / 2, (miny + maxy) / 2)){
BNRImageArea(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight, sthresh * 2, &minx, &miny, &maxx, &maxy);
float lrate = BinzImage(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight) * 100;
if(lrate <= lthresh){
continue;
}
SDeviMaxImage(DffImage, bthresh, SerHeader.ImageWidth, SerHeader.ImageHeight, &ax, &ay, &sx, &sy, &minx, &miny, &maxx, &maxy);
}
if(sx > sthresh || sy > sthresh){
fc++;
if(i != oc + 1){
mc++;
printf("Meteor No. %d, frame No. %d\n", mc, i);
}
oc = i;
cv::Mat OutImage(cv::Size(SerHeader.ImageWidth * 2, SerHeader.ImageHeight), CV_8UC3); // 合成後のイメージ作成
cv::Mat imageLeft(OutImage, cv::Rect( 0, 0, rgb8BitMat.cols, rgb8BitMat.rows)); // コピーする領域左側
cv::Mat imageRight(OutImage, cv::Rect(SerHeader.ImageWidth, 0, rgb8BitMat.cols, rgb8BitMat.rows)); // コピーする領域右側
cv::Mat bayer16BitMat(SerHeader.ImageHeight, SerHeader.ImageWidth, CV_16UC1, NewImage); // 16bit用バッファを用意して取り込み
cv::Mat bayer8BitMat = bayer16BitMat.clone(); // 8bit用バッファを用意
bayer8BitMat.convertTo(bayer8BitMat, CV_8UC1, 0.0625*ratio); // 8bitに変換
cv::cvtColor(bayer8BitMat, rgb8BitMat, cv::COLOR_BayerRG2RGB); // デベイヤー
rgb8BitMat.copyTo(imageRight); // 右側にコピーして表示させる
cv::rectangle(imageRight, cv::Point(ax-1, ay-1), cv::Point(ax+1, ay+1), CV_RGB(255,0,0), 2, 10, 0); // 赤の矩形
cv::rectangle(imageRight, cv::Point(ax-sx, ay-sy), cv::Point(ax+sx, ay+sy), CV_RGB(0,0,255), 2, 10, 0); // 青の矩形
cv::rectangle(imageRight, cv::Point(minx, miny), cv::Point(maxx, maxy), CV_RGB(0,255,0), 2, 10, 0); // 緑の矩形
cv::Mat bayer16BitMat2(SerHeader.ImageHeight, SerHeader.ImageWidth, CV_16UC1, DffImage); // 16bit用バッファを用意して取り込み
bayer8BitMat = bayer16BitMat2.clone(); // 8bit用バッファを用意
bayer8BitMat.convertTo(bayer8BitMat, CV_8UC1, 0.0625*ratio); // 8bitに変換
cv::cvtColor(bayer8BitMat, rgb8BitMat, cv::COLOR_BayerRG2RGB); // デベイヤー
timestamp2date(TrailerDateP[i], &year, &month, &day, &hour, &minute, &second, µsec);
sprintf(str, "%4.4d %4.4d %4.4d:%2.4f%", fc, mc, i, lrate);
cv::putText(rgb8BitMat, str, cv::Point(20, 50),cv::FONT_HERSHEY_SIMPLEX, 1, CV_RGB(200,200,200), 1);
sprintf(str, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%4.4dUTC", year, month, day, hour, minute, second, microsec);
cv::putText(rgb8BitMat, str, cv::Point(20, 100),cv::FONT_HERSHEY_SIMPLEX, 1, CV_RGB(200,200,200), 1);
sprintf(str, "ax:%04.0lf ay:%04.0lf sx:%04.0lf sy:%04.0lf", ax, ay, sx, sy);
cv::putText(rgb8BitMat, str, cv::Point(20, SerHeader.ImageHeight - 20),cv::FONT_HERSHEY_SIMPLEX, 1, CV_RGB(200,200,200), 1);
rgb8BitMat.copyTo(imageLeft); // 左側にコピーして表示させる
fprintf(fpLog,"%4.4d,%4.4d,%s,%4.4d,%4.4d-%2.2d-%2.2d,%2.2d:%2.2d:%2.2d.%4.4dUTC,%2.4f%,"
, fc, mc, path, i, year, month, day, hour, minute, second, microsec, lrate);
fprintf(fpLog,"%3.0lf,%3.0lf,%3.0lf,%3.0lf,%3.0d,%3.0d,%3.0d,%3.0d\n"
, ax, ay, sx, sy, minx, miny, maxx, maxy);
writer << OutImage; // 画像 image を動画ファイルへ書き出す
cv::resize(OutImage, OutImage, cv::Size(), 0.5, 0.5); // 縮小
writer2 << OutImage; // 画像 image を動画ファイルへ書き出す
SLImage(StkImage, DffImage, SerHeader.ImageWidth, SerHeader.ImageHeight, 0);
}
}
}
free(TrailerDateP);
fclose(fpSer);
return 0;
}
リアルタイム版(SensorLounch16)ソース
赤字が前回との差分です。
//-------------------------------------------------------------------
// 画像を読み込み,表示する
//-------------------------------------------------------------------
timeout_counter = 0;
frame_count = oc = 0;
st = GetTime();
zoom_setMouseCallback((char *)"se_cam", 1/(float)div);
while (1) {
if (ReadRAW(RawImage) == 0) {
if (++timeout_counter > TIMEOUT) {
fprintf(stderr, "sensorlaunch: time out.\n");
return 1;
}
usleep(500);
continue;
}
frame_count++;
timeout_counter = 0;
unsigned char *Temp = BinImage3;
BinImage3 = BinImage2;
BinImage2 = Temp;
CnvertImage(BinImage2, RawImage, RawSize, rawbit, raw8_flag);
if(mask_r.data != NULL)
bmask(mask_r, (unsigned short *)BinImage2);
if(mode == SERD_MODE){
int sthresh = 5;
float lthresh = 0.0002;
DifImage((unsigned short *)DiffImage, (unsigned short *)BinImage2, (unsigned short *)BinImage3, width, height, 0);
NRImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height);
if(mask_d.data != NULL)
bmask(mask_d, (unsigned short *)DiffImage);
BinzImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height);
float lrate = CountImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height) * 100;
if(lrate > lthresh){
double ax, ay, sx, sy;
int minx, miny, maxx, maxy;
SDeviMaxImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height, &ax, &ay, &sx, &sy, &minx, &miny, &maxx, &maxy);
if(!GetPix((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height, (minx + maxx) / 2, (miny + maxy) / 2)){
BNRImageArea((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height, sthresh * 2, &minx, &miny, &maxx, &maxy);
float lrate = BinzImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height) * 100;
if(lrate <= lthresh){
continue;
}
SDeviMaxImage((unsigned short *)DiffImage, bthresh >> (16-bpp), width, height, &ax, &ay, &sx, &sy, &minx, &miny, &maxx, &maxy);
}
if(sx > sthresh || sy > sthresh){
printf("%5d:Diff Detect. sx:%04.0lf sy:%04.0lf\n", ++diffcount, sx, sy);
diff = ON;
if(frame_count != oc +1)
system("~/detect_voice.sh");
oc = frame_count;
}
}
// 差分表示用
cv::Mat bayerXBitMat2(height, width, depth, DiffImage); // Xbit用バッファを用意して取り込み
cv::Mat bayer8BitMat2 = bayerXBitMat2.clone(); // 8bit用バッファを用意
resize(bayer8BitMat2, bayer8BitMat2, cv::Size(), 1/(float)div, 1/(float)div); // 縮小
cv::imshow("ImageDiff", bayer8BitMat2); // ウィンドウに画像を表示する
// 差分積算表示用
if(diff == ON){
SLImage((unsigned short *)StkImage, (unsigned short *)DiffImage, width, height, 0);
cv::Mat bayer8BitMat3(height, width, CV_16UC1, StkImage); // 16bit用バッファを用意して取り込み
bayer8BitMat3.convertTo(bayer8BitMat3, CV_8UC1, 0.0625*2); // 8bitに変換
sprintf(str, "%d differences detected", diffcount);
cv::putText(bayer8BitMat3, str, cv::Point(20, 50),cv::FONT_HERSHEY_SIMPLEX, 1, CV_RGB(200,200,200), 1);
resize(bayer8BitMat3, bayer8BitMat3, cv::Size(), 1/(float)div, 1/(float)div); // 縮小
cv::imshow("ImageDiffStack", bayer8BitMat3); // ウィンドウに画像を表示する
}
}
// メインのRAW表示用
cv::Mat bayerXBitMat(height, width, depth, BinImage2); // Xbit用バッファを用意して取り込み
cv::Mat bayer8BitMat = bayerXBitMat.clone(); // 8bit用バッファを用意
if(!raw8_flag){
bayer8BitMat.convertTo(bayer8BitMat, CV_8UC1, 0.02*4); // 8bitに変換
}
cv::Mat rgb8BitMat(height, width, CV_8UC3); // 保存用RGBバッファを用意
cv::Mat dsp8BitMat(height, width, CV_8UC3); // 表示用RGBバッファを用意
cv::cvtColor(bayer8BitMat, rgb8BitMat, cv::COLOR_BayerRG2RGB); // デベイヤー
resize(rgb8BitMat, dsp8BitMat, cv::Size(), 1/(float)div, 1/(float)div); // 縮小
zoom_imshow(rgb8BitMat, dsp8BitMat, 2.0); // 拡大表示ウィンドウに画像を表示する
cv::imshow("se_cam", dsp8BitMat); // ウィンドウに画像を表示する
// キー入力の処理