Exemple #1
0
void Point::save(CvFileStorage *out, const char *name) const {
    cvStartWriteStruct(out, name, CV_NODE_MAP);
    cvWriteReal(out, "x", x);
    cvWriteReal(out, "y", y);
    cvEndWriteStruct(out);
}
Exemple #2
0
void GazeTracker::save(CvFileStorage *out, const char *name) {
    cvStartWriteStruct(out, name, CV_NODE_MAP);
    savevector(out, "caltargets", caltargets);
    cvEndWriteStruct(out);
}
/*
 * Writes Out information of one frame of the worm to a disk
 * in YAML format.
 *
 * Note the Worm object must have the following fields
 * Worm->frameNum
 * Worm->Segmented->Head
 * Worm->Segmented->Tail
 * Worm->Segmented->LeftBound
 * Worm->Segmented->RightBound
 * Worm->Segmented->Centerline
 *
 * and Params object must have
 * Params->DLPOn
 * Params->IllumSegCenter
 * Params->IllumSegRadius
 * Params->IllumLRC
 *
 * And more now!
 */
int AppendWormFrameToDisk(WormAnalysisData* Worm, WormAnalysisParam* Params, WriteOut* DataWriter){

	CvFileStorage* fs=DataWriter->fs;

	cvStartWriteStruct(fs,NULL,CV_NODE_MAP,NULL);
		/** Frame Number Info **/
		cvWriteInt(fs,"FrameNumber",Worm->frameNum);

		/** TimeStamp **/
		cvWriteInt(fs,"sElapsed",GetSeconds(Worm->timestamp));
		cvWriteInt(fs,"msRemElapsed",GetMilliSeconds(Worm->timestamp));


		/** Segmentation Info **/
		if(cvPointExists(Worm->Segmented->Head)){
		cvStartWriteStruct(fs,"Head",CV_NODE_MAP,NULL);
			cvWriteInt(fs,"x",Worm->Segmented->Head->x);
			cvWriteInt(fs,"y",Worm->Segmented->Head->y);
		cvEndWriteStruct(fs);
		}

		if(cvPointExists(Worm->Segmented->Tail)){
		cvStartWriteStruct(fs,"Tail",CV_NODE_MAP,NULL);
			cvWriteInt(fs,"x",Worm->Segmented->Tail->x);
			cvWriteInt(fs,"y",Worm->Segmented->Tail->y);
		cvEndWriteStruct(fs);
		}


		if(cvSeqExists(Worm->Segmented->LeftBound)) cvWrite(fs,"BoundaryA",Worm->Segmented->LeftBound);
		if(cvSeqExists(Worm->Segmented->RightBound)) cvWrite(fs,"BoundaryB",Worm->Segmented->RightBound);
		if(cvSeqExists(Worm->Segmented->Centerline)) cvWrite(fs,"SegmentedCenterline",Worm->Segmented->Centerline);

		/** Illumination Information **/
		cvWriteInt(fs,"DLPIsOn",Params->DLPOn);
		cvWriteInt(fs,"FloodLightIsOn",Params->IllumFloodEverything);
		cvWriteInt(fs,"IllumInvert",Params->IllumInvert);
		cvWriteInt(fs,"IllumFlipLR",Params->IllumFlipLR);

		CvPoint origin=ConvertSlidlerToWormSpace(Params->IllumSquareOrig,Params->DefaultGridSize);
		cvStartWriteStruct(fs,"IllumRectOrigin",CV_NODE_MAP,NULL);
			cvWriteInt(fs,"x",origin.x);
			cvWriteInt(fs,"y",origin.y);
		cvEndWriteStruct(fs);

		cvStartWriteStruct(fs,"IllumRectRadius",CV_NODE_MAP,NULL);
			cvWriteInt(fs,"x",Params->IllumSquareRad.width);
			cvWriteInt(fs,"y",Params->IllumSquareRad.height);
		cvEndWriteStruct(fs);

		if (Params->stageTrackingOn){
			cvStartWriteStruct(fs,"StageVelocity",CV_NODE_MAP,NULL);
				cvWriteInt(fs,"i",Worm->stageVelocity.x);
				cvWriteInt(fs,"j",Worm->stageVelocity.y);
			cvEndWriteStruct(fs);
		}

		/** Protocol Information **/

		cvWriteInt(fs,"ProtocolIsOn",Params->ProtocolUse);
		cvWriteInt(fs,"ProtocolStep",Params->ProtocolStep);
	cvEndWriteStruct(fs);

	return 0;
}
Exemple #4
0
    void SaveAll() {
        int     ObjNum = m_TrackList.GetBlobNum();
        int     i;
        char    video_name[1024];
        char*   struct_name = NULL;
        CvFileStorage* storage = cvOpenFileStorage(m_pFileName, NULL, CV_STORAGE_WRITE_TEXT);

        if (storage == NULL) {
            printf("WARNING!!! Cannot open %s file for trajectory output.", m_pFileName);
        }

        for (i = 0; i < 1024 && m_pFileName[i] != '.' && m_pFileName[i] != 0; ++i) { video_name[i] = m_pFileName[i]; }
        video_name[i] = 0;

        for (; i > 0; i--) {
            if (video_name[i-1] == '\\') { break; }
            if (video_name[i-1] == '/') { break; }
            if (video_name[i-1] == ':') { break; }
        }
        struct_name = video_name + i;

        cvStartWriteStruct(storage, struct_name, CV_NODE_SEQ);

        for (i = 0; i < ObjNum; ++i) {
            char            obj_name[1024];
            DefBlobTrack*   pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i);
            if (pTrack == NULL) { continue; }
            sprintf(obj_name, "%s_obj%d", struct_name, i);
            cvStartWriteStruct(storage, NULL, CV_NODE_MAP);
            cvWriteInt(storage, "FrameBegin", pTrack->FrameBegin);
            cvWriteString(storage, "VideoObj", obj_name);
            cvEndWriteStruct(storage);
            pTrack->Saved = 1;
        }
        cvEndWriteStruct(storage);

        for (i = 0; i < ObjNum; ++i) {
            char            obj_name[1024];
            DefBlobTrack*   pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i);
            CvBlobSeq*      pSeq = pTrack->pSeq;
            sprintf(obj_name, "%s_obj%d", struct_name, i);
            cvStartWriteStruct(storage, obj_name, CV_NODE_MAP);

            {
                /* Write position: */
                int             j;
                CvPoint2D32f    p;
                cvStartWriteStruct(storage, "Pos", CV_NODE_SEQ | CV_NODE_FLOW);
                for (j = 0; j < pSeq->GetBlobNum(); ++j) {
                    CvBlob* pB = pSeq->GetBlob(j);
                    p.x = pB->x / (m_Size.width - 1);
                    p.y = pB->y / (m_Size.height - 1);
                    cvWriteRawData(storage, &p, 1 , "ff");
                }
                cvEndWriteStruct(storage);
            }

            {
                /* Write size: */
                int             j;
                CvPoint2D32f    p;
                cvStartWriteStruct(storage, "Size", CV_NODE_SEQ | CV_NODE_FLOW);

                for (j = 0; j < pSeq->GetBlobNum(); ++j) {
                    CvBlob* pB = pSeq->GetBlob(j);
                    p.x = pB->w / (m_Size.width - 1);
                    p.y = pB->h / (m_Size.height - 1);
                    cvWriteRawData(storage, &p, 1 , "ff");
                }
                cvEndWriteStruct(storage);
            }
            cvEndWriteStruct(storage);
        }
        cvReleaseFileStorage(&storage);

    }   /* Save All */
Exemple #5
0
void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num)
{
    cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW);
    cvWriteRawData(fs,addr,num,desc);
    cvEndWriteStruct(fs);
}
Exemple #6
0
// Save XML-formatted configuration file.
void writeConfiguration(const char* filename, struct slParams* sl_params){

	// Create file storage for XML-formatted configuration file.
	CvFileStorage* fs = cvOpenFileStorage(filename, 0, CV_STORAGE_WRITE);
	
	// Write output directory and object (or sequence) name.
	cvStartWriteStruct(fs, "output", CV_NODE_MAP);
	cvWriteString(fs, "output_directory",          sl_params->outdir, 1);
	cvWriteString(fs, "object_name",               sl_params->object, 1);
	cvWriteInt(fs,    "save_intermediate_results", sl_params->save);
	cvEndWriteStruct(fs);
	
	// Write camera parameters.
	cvStartWriteStruct(fs, "camera", CV_NODE_MAP);
	cvWriteInt(fs, "width",                           sl_params->cam_w);
	cvWriteInt(fs, "height",                          sl_params->cam_h);
	cvWriteInt(fs, "Logitech_Quickcam_9000_raw_mode", sl_params->Logitech_9000);
	cvEndWriteStruct(fs);

	// Write projector parameters.
	cvStartWriteStruct(fs, "projector", CV_NODE_MAP);
	cvWriteInt(fs, "width",            sl_params->proj_w);
	cvWriteInt(fs, "height",           sl_params->proj_h);
	cvWriteInt(fs, "invert_projector", sl_params->proj_invert);
	cvEndWriteStruct(fs);

	// Write camera and projector gain parameters.
	cvStartWriteStruct(fs, "gain", CV_NODE_MAP);
	cvWriteInt(fs, "camera_gain",    sl_params->cam_gain);
	cvWriteInt(fs, "projector_gain", sl_params->proj_gain);
	cvEndWriteStruct(fs);

	// Write distortion model parameters.
	cvStartWriteStruct(fs, "distortion_model", CV_NODE_MAP);
	cvWriteInt(fs, "enable_tangential_camera",          sl_params->cam_dist_model[0]);
	cvWriteInt(fs, "enable_6th_order_radial_camera",    sl_params->cam_dist_model[1]);
	cvWriteInt(fs, "enable_tangential_projector",       sl_params->proj_dist_model[0]);
	cvWriteInt(fs, "enable_6th_order_radial_projector", sl_params->proj_dist_model[1]);
	cvEndWriteStruct(fs);

	// Write camera calibration chessboard parameters.
	cvStartWriteStruct(fs, "camera_chessboard", CV_NODE_MAP);
	cvWriteInt(fs,  "interior_horizontal_corners",  sl_params->cam_board_w);
	cvWriteInt(fs,  "interior_vertical_corners",    sl_params->cam_board_h);
	cvWriteReal(fs, "square_width_mm",              sl_params->cam_board_w_mm);
	cvWriteReal(fs, "square_height_mm",             sl_params->cam_board_h_mm);
	cvEndWriteStruct(fs);

	// Write projector calibration chessboard parameters.
	cvStartWriteStruct(fs, "projector_chessboard", CV_NODE_MAP);
	cvWriteInt(fs, "interior_horizontal_corners",  sl_params->proj_board_w);
	cvWriteInt(fs, "interior_vertical_corners",    sl_params->proj_board_h);
	cvWriteInt(fs, "square_width_pixels",          sl_params->proj_board_w_pixels);
	cvWriteInt(fs, "square_height_pixels",         sl_params->proj_board_h_pixels);
	cvEndWriteStruct(fs);

	// Write scanning and reconstruction parameters.
	cvStartWriteStruct(fs, "scanning_and_reconstruction", CV_NODE_MAP);
	cvWriteInt(fs,  "mode",                           sl_params->mode);
	cvWriteInt(fs,  "reconstruct_columns",            sl_params->scan_cols);
	cvWriteInt(fs,  "reconstruct_rows",               sl_params->scan_rows);
	cvWriteInt(fs,  "frame_delay_ms",                 sl_params->delay);
	cvWriteInt(fs,  "minimum_contrast_threshold",     sl_params->thresh);
	cvWriteReal(fs, "minimum_distance_mm",            sl_params->dist_range[0]);
	cvWriteReal(fs, "maximum_distance_mm",            sl_params->dist_range[1]);
	cvWriteReal(fs, "maximum_distance_variation_mm",  sl_params->dist_reject);
	cvWriteReal(fs, "minimum_background_distance_mm", sl_params->background_depth_thresh);
	cvEndWriteStruct(fs);

	// Write visualization options.
	cvStartWriteStruct(fs, "visualization", CV_NODE_MAP);
	cvWriteInt(fs, "display_intermediate_results", sl_params->display);
	cvWriteInt(fs, "display_window_width_pixels",  sl_params->window_w);
	cvEndWriteStruct(fs);

	// Close file storage for XML-formatted configuration file.
	cvReleaseFileStorage(&fs);
}