46 uint32_t width, height;
50 std::vector<gige_acknowledge_ack> gige_list;
52 std::string extra =
"";
61 binning=atol(argv[5]);
65 exposure = atol(argv[3]);
69 strcpy(ipaddress, argv[1]);
72 printf(
"Usage: gigesnap ipaddress [extraname [exposure [gain [binning]]]]\n");
78 if (!gige_list.size())
80 printf(
"Couldn't find any cameras\n");
86 uint32_t used_exposure=0;
87 uint32_t used_imagewidth=0;
88 uint32_t used_imageheight=0;
90 std::string imagename =
"testimage.imgdata";
91 std::string metafilename =
"testimage.imgmeta";
92 std::string fringename =
"testimage.imgfringe";
102 current_time = time(NULL);
105 if (current_time == ((time_t)-1))
108 (void) fprintf(stderr,
"Failure to compute the current time.");
112 c_time_string = ctime(¤t_time);
114 if (c_time_string == NULL)
116 (void) fprintf(stderr,
"Failure to convert the current time.");
127 if ((handle=
gige_open(ipaddress,0x02,40000,5000,7500000)) == NULL)
131 printf(
"Couldn't open camera\n");
137 printf(
"Read CCP: %u\n",iretn);
140 printf(
"Read DEVICE_MAC_HIGH: %0x\n",iretn);
143 printf(
"Read DEVICE_MAC_LOW: %0x\n",iretn);
146 printf(
"Read CCP: %u\n",iretn);
149 printf(
"Read VERSION: %u\n",iretn);
152 printf(
"Read DEVICE_MODE: %u\n",iretn);
155 printf(
"Read GVCP_HEARTBEAT_TIMEOUT %u\n",iretn);
158 printf(
"Read PRIMARY_APPLICATION_IP_ADDRESS %x\n",iretn);
206 if( strncmp((
char *)handle->
cack_mem.
data,
"FLIR AX5", 8) == 0 )
212 printf(
"Read A35_WIDTH %d\n",width);
215 printf(
"Read A35_HEIGHT %d\n",height);
218 expbytes = width * height * exposure * 2;
221 if (expbytes == tbytes)
224 FILE *fp = fopen(fringename.c_str(),
"w");
225 fprintf(fp,
"Fringes\n");
226 uint16_t *cube = (uint16_t *)
image;
227 float mean[336][256];
230 for (uint32_t icol=0; icol<336; ++icol)
233 for (uint32_t irow=0; irow<256; ++irow)
235 mean[icol][irow] = 0.;
236 for (uint32_t ilayer=0; ilayer<exposure; ++ilayer)
238 mean[icol][irow] += cube[ilayer*336*256+irow*336+icol];
240 mean[icol][irow] /= (float)exposure;
241 if (mean[icol][irow] > high[icol])
243 high[icol] = mean[icol][irow];
244 printf(
"[%d,%d] %f\r",icol,irow,high[icol]);
250 for (uint32_t irow=0; irow<256; ++irow)
253 for (uint32_t icol=0; icol<336; ++icol)
255 fringe[irow] += mean[icol][irow] / mean[icol][0];
257 fringe[irow] /= 336.;
258 fprintf(fp,
"%.4g\n",fringe[irow]);
265 else if (strncmp((
char *)handle->
cack_mem.
data,
"PT1000", 6) == 0 )
268 printf(
"Read PT1000PIXELFORMAT %d\n",iretn);
271 printf(
"Read PT1000_WIDTH %d\n",width);
275 printf(
"Read PT1000_HEIGHT %d\n",height);
283 expbytes = width * height * exposure * 2;
286 if (expbytes == tbytes)
289 fp = fopen(
"pt1000_test.img",
"wb");
290 fwrite((
void *)
image,tbytes,1,fp);
293 fp = fopen(
"pt1000_test",
"w");
294 uint16_t *cube = (uint16_t *)
image;
295 vector<vector<float>> mean;
299 for (uint32_t icol=0; icol<width; ++icol)
302 mean[icol].resize(height);
303 for (uint32_t irow=0; irow<height; ++irow)
305 mean[icol][irow] = 0.;
306 for (uint32_t ilayer=0; ilayer<exposure; ++ilayer)
308 mean[icol][irow] += cube[ilayer*width*height+irow*width+icol];
310 mean[icol][irow] /= (float)exposure;
311 if (mean[icol][irow] > high[icol])
313 high[icol] = mean[icol][irow];
314 printf(
"[%d,%d] %f\r",icol,irow,high[icol]);
324 printf(
"Read PT1000_AcquisitionMode %d\n",iretn);
327 printf(
"Read PT1000_PixelFormat %d\n",iretn);
330 printf(
"Read PT1000_SensorWidth %d\n",iretn);
333 printf(
"Read PT1000_SensorHeight %d\n",iretn);
336 printf(
"Read PT1000_Width %d\n",iretn);
339 printf(
"Read PT1000_Height %d\n",iretn);
371 printf(
"Read PROSILICA_MaxWidth %d\n",width);
374 printf(
"Read PROSILICA_MaxHeight %d\n",height);
392 expbytes = width * height * 2;
396 printf(
"Read PROSILICA_ExposureValue %d\n",used_exposure);
406 if (expbytes == tbytes)
409 printf(
"\nRead: %d bytes ",tbytes);
410 uint32_t counts[4]={0,0,0,0};
411 uint16_t *array=(uint16_t *)
image;
415 int16_t min_value=4095.;
416 int16_t max_value=0.;
420 for (int32_t
i=0;
i<tbytes/2; ++
i)
423 std += (array[
i]*array[
i]);
424 ++counts[array[
i]/1024];
426 if (array[
i]<min_value){
430 if (array[
i]>max_value)
435 std = sqrt((std-(mean*mean/(tbytes/2)))/(tbytes/2)-1);
439 printf(
"%u %u %u %u %f %f %f\n\n",counts[0],counts[1],counts[2],counts[3],mean,std, snr);
441 printf(
"Read GIGE_REG_STREAM_CHANNEL_PACKET_SIZE %d\n",iretn);
444 printf(
"Read GIGE_STREAM_CHANNEL_DESTINATION_ADDRESS %x\n",iretn);
447 printf(
"___________________________ \n\n");
448 printf(
"Mean Image Value = %f\n",mean);
449 printf(
"Standard Deviation = %f\n",std);
450 printf(
"SNR = %f\n",snr);
451 printf(
"Min/Max = %d, %d \n",min_value, max_value);
459 fp = fopen(imagename.c_str(),
"wb");
460 fwrite((
void *)
image,tbytes,1,fp);
467 FILE *f = fopen(metafilename.c_str(),
"wb");
470 printf(
"Error opening file!\n");
475 fprintf(f,
"Image Name = %s\n",imagename.c_str());
476 fprintf(f,
"IP Address = %s\n",ipaddress);
477 fprintf(f,
"Acq Timestamp = %f\n",
currentmjd(0.));
478 fprintf(f,
"Acq Date = %s",c_time_string);
479 fprintf(f,
"Exposure = %d\n",used_exposure);
480 fprintf(f,
"Pixel Binning = %d\n",binning);
481 fprintf(f,
"Image Width = %d\n",used_imagewidth);
482 fprintf(f,
"Image Height = %d\n",used_imageheight);
483 fprintf(f,
"Mean Image Value = %f\n",mean);
484 fprintf(f,
"Standard Deviation = %f\n",std);
485 fprintf(f,
"SNR = %f\n",snr);
486 fprintf(f,
"Min/Max = %d, %d \n",min_value, max_value);
492 printf(
"Error: Expected %d bytes, Read %d bytes\n", expbytes, tbytes);
#define PROSILICA_PixelFormat_BayerRG12
Definition: gige_lib.h:191
int pt1000_image(gige_handle *handle, uint32_t frames, uint8_t *buffer, uint16_t bsize)
Take PT1000 image stream.
Definition: gige_lib.cpp:574
gige_acknowledge_mem cack_mem
Definition: gige_lib.h:349
uint8_t image[110000000]
Definition: gige_snap.cpp:38
#define A35_TEMPERATUREFPA
Definition: gige_lib.h:427
#define GIGE_REG_DEVICE_MODE
Definition: gige_lib.h:81
uint16_t bsize
Definition: netperf_listen.cpp:71
Definition: gige_lib.h:480
int i
Definition: rw_test.cpp:37
int prosilica_image(gige_handle *handle, uint16_t emode, uint32_t exposure, uint32_t gain, uint8_t *buffer, uint16_t bsize)
Take Prosilica image.
Definition: gige_lib.cpp:687
int a35_config(gige_handle *handle, uint32_t xsize, uint32_t ysize, uint32_t video_rate)
Configure a35 camera.
Definition: gige_lib.cpp:441
Definition: gige_lib.h:476
#define GIGE_REG_SCDA
Definition: gige_lib.h:143
int iretn
Definition: rw_test.cpp:37
#define PROSILICA_PayloadSize
Definition: gige_lib.h:196
#define PROSILICA_Width
Definition: gige_lib.h:192
vector< gige_acknowledge_ack > gige_discover()
Discover GIGE Camera.
Definition: gige_lib.cpp:332
#define PROSILICA_RegionX
Definition: gige_lib.h:194
#define PROSILICA_Height
Definition: gige_lib.h:193
#define PROSILICA_ExposureValue
Definition: gige_lib.h:220
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
Definition: gige_lib.h:475
#define A35_PIXELFORMAT
Definition: gige_lib.h:420
Definition: gige_lib.h:482
char address[]
Definition: netperf_listen.cpp:69
#define A35_SENSORVIDEOSTANDARD_30HZ
Definition: gige_lib.h:447
string data_type_path(string node, string location, string agent, double mjd, string type)
Create data file path.
Definition: datalib.cpp:910
#define PROSILICA_BinningYValue
Definition: gige_lib.h:178
#define GIGE_REG_VERSION
Definition: gige_lib.h:80
int prosilica_config(gige_handle *handle, uint32_t format, uint32_t xbin, uint32_t ybin, uint32_t xsize, uint32_t ysize, uint32_t xoffset, uint32_t yoffset)
Configure Prosilica camera.
Definition: gige_lib.cpp:640
#define GIGE_MAX_MODEL_NAME
Definition: gige_lib.h:155
#define GIGE_REG_PRIMARY_APPLICATION_IP_ADDRESS
Definition: gige_lib.h:128
char * gige_value_to_address(uint32_t value)
IP Value to address.
Definition: gige_lib.cpp:418
#define PROSILICA_RegionY
Definition: gige_lib.h:195
uint32_t gige_readreg(gige_handle *handle, uint32_t address)
Read GIGE Register.
Definition: gige_lib.cpp:237
#define PROSILICA_MaxHeight
Definition: gige_lib.h:181
#define GIGE_REG_CCP
Definition: gige_lib.h:126
uint32_t gige_readmem(gige_handle *handle, uint32_t address, uint32_t size)
Read GIGE memory.
Definition: gige_lib.cpp:284
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
#define PROSILICA_ExposureMode_AutoOff
Do not automatically adjust exposure.
Definition: gige_lib.h:213
#define GIGE_REG_GVCP_HEARTBEAT_TIMEOUT
Definition: gige_lib.h:110
#define PROSILICA_AcquisitionMode
Definition: gige_lib.h:201
uint8_t data[600-12]
Definition: gige_lib.h:278
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
int pt1000_config(gige_handle *handle, uint32_t xsize, uint32_t ysize)
Configure pt1000 camera.
Definition: gige_lib.cpp:541
gige_handle * gige_open(char address[18], uint8_t privilege, uint32_t heartbeat_msec, uint32_t socket_usec, uint32_t streambps)
Connect to camera.
Definition: gige_lib.cpp:64
Definition: gige_lib.h:477
int a35_image(gige_handle *handle, uint32_t frames, uint8_t *buffer, uint16_t bsize)
Take A35 image stream.
Definition: gige_lib.cpp:479
Definition: gige_lib.h:474
#define A35_TEMPERATURE
Definition: gige_lib.h:426
#define GIGE_REG_SCPS
Definition: gige_lib.h:139
FILE * fp
Definition: rw_test.cpp:38
#define PROSILICA_ExposureMode_Auto
Adjust exposure on each frame.
Definition: gige_lib.h:217
#define GIGE_REG_DEVICE_MAC_HIGH
Definition: gige_lib.h:82
Definition: gige_lib.h:336
#define PROSILICA_SensorWidth
Definition: gige_lib.h:173
#define EXIT_FAILURE
Definition: cdjpeg.h:169
#define PROSILICA_PixelFormat
Definition: gige_lib.h:182
#define PROSILICA_StreamBytesPerSec
Definition: gige_lib.h:179
#define GIGE_REG_DEVICE_MAC_LOW
Definition: gige_lib.h:83
#define PROSILICA_BinningXValue
Definition: gige_lib.h:176
#define PROSILICA_MaxWidth
Definition: gige_lib.h:180
#define PROSILICA_SensorHeight
Definition: gige_lib.h:174
#define GIGE_REG_MODEL_NAME
Definition: gige_lib.h:90
uint16_t bestsize
Best packet size.
Definition: gige_lib.h:359
void gige_close(gige_handle *handle)
Close GigE Camera.
Definition: gige_lib.cpp:177