-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcamera.cpp
More file actions
executable file
·69 lines (59 loc) · 1.83 KB
/
camera.cpp
File metadata and controls
executable file
·69 lines (59 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
g++ camera.cpp -lusb -lopenssag -o camera
./camera [function] [file_name] [EXP]
./camera image bias1 0
convert -size 1280x1024 -depth 8 gray:image image.jpg
**/
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "openssag.h"
#include <string.h>
// #include "fitsio.h"
using namespace OpenSSAG;
using namespace std;
char name[256];
double expose=1000;
int main(int argc, char *args[]){
// now take the args and call some functions. maybe add a start and exit, or something clever.
void image(char* name, double expose, int gain);
cout << args[1] << ' ' << args[2] << ' ' << args[3] << ' ' << args[4] << endl;
if (strcmp(args[1],"test")==0){
cout << "acknowledge test" << endl;
} else if (strcmp(args[1],"image")==0){
// file_name, exposure
image(args[2],atof(args[3]),atof(args[4]));
} else {
cout << "Did not recognize command" << endl;
}
}
void image(char *name, double expose, int gain){
OpenSSAG::SSAG *camera = new OpenSSAG::SSAG();
if (camera->Connect()) {
camera->SetGain((int)gain);
struct raw_image *image = camera->Expose(expose);
FILE *fp = fopen(name, "w");
fwrite(image->data, 1, image->width * image->height, fp);
fclose(fp);
camera->Disconnect();
}
else {
printf("Could not find StarShoot Autoguider\n");
}
}
/*
try {
// write the image to a fits file…
fitsfile *fptr;
fits_create_file (&fptr, "!" + name + ".fits", &status);
fits_create_img (fptr, FLOAT_IMG,1280,1024,&status);
// Write a keyword – its the address you pass /
fits_update_key(fptr,TLONG,"EXPOSURE",&expose,comment,&status);
// write an array to the image
fits_write_img(fptr, raw_image(), 1280, 1024, pixels[0],&status);
fits_close_file(fptr,&status);
status = 0 ;
}
catch (std::string message)
}
*/