Skip to content

Commit

Permalink
user can specify desired roi. compiles. records. tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
aleifer committed Dec 11, 2014
1 parent bb99651 commit e899d38
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 18 deletions.
5 changes: 3 additions & 2 deletions MyLibs/Talk2FrameGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ FrameGrabber* CreateFrameGrabberObject(){
* and prepares the FrameGrabber for Acuisiation
*
*/
FrameGrabber* TurnOnFrameGrabber(){
FrameGrabber* TurnOnFrameGrabber(int desiredWidth, int desiredHeight){
FrameGrabber* fg= CreateFrameGrabberObject();
InitializeFrameGrabber(fg);
//FrameGrabberSetRegionOfInterest(fg,0,127,1024,768);
//FrameGrabberSetRegionOfInterest(fg,0,0,1024,768);

FrameGrabberSetRegionOfInterest(fg,0,0,desiredWidth,desiredHeight);
PrepareFrameGrabberForAcquire(fg);
return fg;
}
Expand Down
2 changes: 1 addition & 1 deletion MyLibs/Talk2FrameGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ FrameGrabber* CreateFrameGrabberObject();
* and prepares the FrameGrabber for Acuisiation
*
*/
FrameGrabber* TurnOnFrameGrabber();
FrameGrabber* TurnOnFrameGrabber(int desiredWidth, int desiredHeight);

/*
* Initializes the frame grabber with a fg object
Expand Down
7 changes: 6 additions & 1 deletion MyLibs/WormAnalysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,12 +1091,17 @@ int CreateWormHUDS(IplImage* TempImage, WormAnalysisData* Worm, WormAnalysisPara
//cvDrawContours(TempImage, Worm->Boundary, cvScalar(255,0,0),cvScalar(0,255,0),100);

DrawSequence(&TempImage,Worm->Boundary);

// DrawSequence(&TempImage,Worm->Segmented->LeftBound);
// DrawSequence(&TempImage,Worm->Segmented->RightBound);

if (!(Worm->Tail==NULL) && !(Worm->Head==NULL)) {


cvCircle(TempImage,*(Worm->Tail),CircleDiameterSize,cvScalar(255,255,255),1,CV_AA,0);
cvCircle(TempImage,*(Worm->Head),CircleDiameterSize/2,cvScalar(255,255,255),1,CV_AA,0);

}

/** Prepare Text **/
CvFont font;
Expand Down
40 changes: 36 additions & 4 deletions MyLibs/experiment.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Experiment* CreateExperimentStruct() {
/** Input Dimensions **/
exp->inputWidth=0;
exp->inputHeight=0;
exp->desiredInputSizeProvided=0; // 1 means the user provided only a width or height, 2 means the user provided both a width and a height
exp->desiredInputWidth=0;
exp->desiredInputHeight=0;

/** FrameGrabber Input **/
exp->fg = NULL;
Expand Down Expand Up @@ -234,6 +237,9 @@ void displayHelp() {
printf("\t-t\n\t\tUse USB stage tracker.\n\n");
printf("\t-x\n\tx 512\t Target x position of worm for stage feedback loop. 0 is left.\n\n");
printf("\t-y\n\ty 384\t Target y position of worm for stage feedback loop. 0 is top.\n\n");
printf("\t-w 1088 \n\t\t Set the desired camera ROI width to 1088 (note this only works for the framegrabber) and must be consistent with pylon.\n\n");
printf("\t-h 1088 \n\t\t Set the desired camera ROI height to 1088 (note this only works for the framegrabber) and must be consistent with pylon.\n\n");

printf(
"\t-p protocol.yml\n\t\tIlluminate according to a YAML protocol file.\n\n");
printf("\t-?\n\t\tDisplay this help.\n\n");
Expand All @@ -251,7 +257,7 @@ int HandleCommandLineArguments(Experiment* exp) {
opterr = 0;

int c;
while ((c = getopt(exp->argc, exp->argv, "sri:d:o:p:gtx:y:?")) != -1) {
while ((c = getopt(exp->argc, exp->argv, "sri:d:o:p:gtx:y:w:h:?")) != -1) {
switch (c) {
case 'i': /** specify input video file **/
exp->VidFromFile = 1;
Expand Down Expand Up @@ -327,6 +333,20 @@ int HandleCommandLineArguments(Experiment* exp) {
}
printf("Stage feedback target y= %d pixels.\n",exp->stageFeedbackTarget.y );
break;

case 'w': /** Pass in a desired camera input width **/
if (optarg != NULL) {
exp->desiredInputWidth = atoi(optarg);
exp->desiredInputSizeProvided=exp->desiredInputSizeProvided + 1;
}
break;

case 'h': /** Pass in a desired camera input width **/
if (optarg != NULL) {
exp->desiredInputHeight = atoi(optarg);
exp->desiredInputSizeProvided=exp->desiredInputSizeProvided + 1;
}
break;


case '?':
Expand Down Expand Up @@ -1046,12 +1066,24 @@ void RollVideoInput(Experiment* exp) {
/** Use source from camera **/
if (exp->UseFrameGrabber) {
/**Use Frame Grabber **/
exp->fg = TurnOnFrameGrabber();

if (exp->desiredInputSizeProvided==2){
// if the user provided a desired width and hegiht
exp->inputWidth=exp->desiredInputWidth;
exp->inputHeight=exp->desiredInputHeight;

}else{

exp->inputWidth=exp->fg->xsize;
exp->inputHeight=exp->fg->ysize;
}


exp->fg = TurnOnFrameGrabber(exp->inputWidth, exp->inputHeight);

printf("Query frame grabber for size of images..\n");

exp->inputWidth=exp->fg->xsize;
exp->inputHeight=exp->fg->ysize;




Expand Down
3 changes: 3 additions & 0 deletions MyLibs/experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ typedef struct ExperimentStruct{
/** Input Dimensions **/
int inputWidth;
int inputHeight;
int desiredInputSizeProvided; // 1 means the user provided only a width or height, 2 means the user provided both a width and a height
int desiredInputWidth;
int desiredInputHeight;

/** MostRecently Observed CameraFrameNumber **/
unsigned long lastFrameSeenOutside;
Expand Down
2 changes: 1 addition & 1 deletion calibrateFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ int main (int argc, char** argv){
c->LoopsPerPt=20; // Number of frames we use to calibrate a given point

/** Start Camera **/
c->fg= TurnOnFrameGrabber();
c->fg= TurnOnFrameGrabber(NSIZEX,NSIZEY);

/** Set the acquisition timeout to be very long to give the camera time to take long exposures, as is typical with calibration **/
setAcquisitionTimeout(c->fg,200);
Expand Down
22 changes: 13 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ int main (int argc, char** argv){
/** Handle head-tail illumination sweep **/
HandleIlluminationSweep(exp);



/** Load Image into Our Worm Objects **/

Expand All @@ -232,44 +231,45 @@ int main (int argc, char** argv){

/** Apply Levels**/ //Note this is slightly redundant with LoadWormImg
if (exp->e == 0) exp->e=simpleAdjustLevels(exp->fromCCD->iplimg, exp->Worm->ImgOrig, exp->Params->LevelsMin, exp->Params->LevelsMax);


TICTOC::timer().tic("EntireSegmentation");
/** Do Segmentation **/
DoSegmentation(exp);
if (exp->RecordOnly==0) DoSegmentation(exp);
TICTOC::timer().toc("EntireSegmentation");



/** Real-Time Curvature Phase Analysis, and phase induced illumination **/
HandleCurvaturePhaseAnalysis(exp);


/** If the DLP is not displaying right now, than turn off the mirrors */
ClearDLPifNotDisplayingNow(exp);



/* Transform the segmented worm coordinates into DLP space */
/* Note that this is much more computationally efficient than to transform the original image
or to transform the resulting illumination pattern */

TICTOC::timer().tic("TransformSegWormCam2DLP");
if (exp->e == 0 && exp->RecordOnly!=0){
if (exp->e == 0 && exp->RecordOnly==0){
TransformSegWormCam2DLP(exp->Worm->Segmented, exp->segWormDLP,exp->Calib);
}
TICTOC::timer().toc("TransformSegWormCam2DLP");

/** Handle the Choise of Illumination Protocol Here**/
/** ANDY: write this here **/
if (exp->RecordOnly!=0) HandleTimedSecondaryProtocolStep(exp->p,exp->Params);

if (exp->RecordOnly==0) HandleTimedSecondaryProtocolStep(exp->p,exp->Params);

/*** Do Some Illumination ***/

/** Clear the illumination pattern **/
SetFrame(exp->forDLP,0);
SetFrame(exp->IlluminationFrame,0);

if (exp->e == 0 && exp->RecordOnly!=0) {
if (exp->e == 0 && exp->RecordOnly==0) {
if (exp->Params->IllumFloodEverything) {
SetFrame(exp->IlluminationFrame,128); // Turn all of the pixels on
SetFrame(exp->forDLP,128); // Turn all of the pixels o
Expand Down Expand Up @@ -301,16 +301,20 @@ int main (int argc, char** argv){
}



TICTOC::timer().tic("SendFrameToDLP");
if (exp->e == 0 && exp->Params->DLPOn && !(exp->SimDLP)) T2DLP_SendFrame((unsigned char *) exp->forDLP->binary, exp->myDLP); // Send image to DLP
TICTOC::timer().toc("SendFrameToDLP");


/*** DIsplay Some Monitoring Output ***/
if (exp->e == 0) CreateWormHUDS(exp->HUDS,exp->Worm,exp->Params,exp->IlluminationFrame);


if (exp->e==0 && exp->stageIsPresent==1) MarkRecenteringTarget(exp);



if (exp->e == 0 && EverySoOften(exp->Worm->frameNum,exp->Params->DispRate) ){
TICTOC::timer().tic("DisplayOnScreen");
/** Setup Display but don't actually send to screen **/
Expand Down

0 comments on commit e899d38

Please sign in to comment.