int main()
{
   setup_array();

   output_file();

   calc();

   show_values();

}
Exemple #2
0
static int
parse_exif( VipsImage *im, void *data, int data_length )
{
#ifdef HAVE_EXIF
    {
        ExifData *ed;
        VipsExif ve;

        if( !(ed = exif_data_new_from_data( data, data_length )) )
            return( -1 );

#ifdef DEBUG_VERBOSE
        show_tags( ed );
        show_values( ed );
#endif /*DEBUG_VERBOSE*/

        /* Attach informational fields for what we find.

        	FIXME ... better to have this in the UI layer?

        	Or we could attach non-human-readable tags here (int,
        	double etc) and then move the human stuff to the UI
        	layer?

         */
        ve.image = im;
        ve.ed = ed;
        exif_data_foreach_content( ed,
        (ExifDataForeachContentFunc) attach_exif_content, &ve );

        /* Look for resolution fields and use them to set the VIPS
         * xres/yres fields.
         */
        res_from_exif( im, ed );

        attach_thumbnail( im, ed );

        exif_data_free( ed );
    }
#endif /*HAVE_EXIF*/

    return( 0 );
}
Exemple #3
0
/* Scan the exif block on the image, if any, and make a set of vips metadata 
 * tags for what we find.
 */
int
vips__exif_parse( VipsImage *image )
{
	void *data;
	size_t length;
	ExifData *ed;
	VipsExifParams params;
	const char *str;

	if( !vips_image_get_typeof( image, VIPS_META_EXIF_NAME ) )
		return( 0 );
	if( vips_image_get_blob( image, VIPS_META_EXIF_NAME, &data, &length ) )
		return( -1 ); 
	if( !(ed = vips_exif_load_data_without_fix( data, length )) )
		return( -1 );

#ifdef DEBUG_VERBOSE
	show_tags( ed );
	show_values( ed );
#endif /*DEBUG_VERBOSE*/

	/* Look for resolution fields and use them to set the VIPS xres/yres 
	 * fields.
	 *
	 * If the fields are missing, set them from the image, which will have
	 * previously had them set from something like JFIF. 
	 */
	if( vips_image_resolution_from_exif( image, ed ) &&
		vips_exif_resolution_from_image( ed, image ) ) {
		exif_data_free( ed );
		return( -1 ); 
	}

	/* Make sure all required fields are there before we attach the vips
	 * metadata.
	 */
	exif_data_fix( ed );

	/* Attach informational fields for what we find.
	 */
	params.image = image;
	params.ed = ed;
	exif_data_foreach_content( ed, 
		(ExifDataForeachContentFunc) vips_exif_get_content, &params );

	vips_exif_get_thumbnail( image, ed );
	exif_data_free( ed );

	/* Orientation handling. ifd0 has the Orientation tag for the main
	 * image. 
	 */
	if( vips_image_get_typeof( image, "exif-ifd0-Orientation" ) != 0 &&
		!vips_image_get_string( image, 
			"exif-ifd0-Orientation", &str ) ) {
		int orientation;

		orientation = atoi( str );
		orientation = VIPS_CLIP( 1, orientation, 8 );
		vips_image_set_int( image, VIPS_META_ORIENTATION, orientation );
	}

	return( 0 );
}
void GCSWrapper::angle_line_circle(int id1, int id2, double angle)	// id1 = line, id2 = circle
{
	SaLine* l = (SaLine*)get_shape(id1);
	SaCircle* c = (SaCircle*)get_shape(id2);

	GCS::Point p = c->get_gcs_circle().center;
	
	// getting values from line
	double l_x1 = *(l->get_gcs_line().p1.x);
	double l_x2 = *(l->get_gcs_line().p2.x);

	// making new point - point C
	double c_x = *p.x;
	double c_y = *p.y;
	
	//std::cout<<c_x<<"\n";
	//std::cout<<c_y<<"\n";

	// std::cout<<c_x<<"\n";
	int p1 = add_point(c_x, c_y);
	show_values(0);

	collinear_point_line(p1, id1);
	
	solve();

	std::cout<<"Values after first solve"<<"\n";
	show_values(0);

	double x = *(_Parameters[_Parameters.size()-2]);
	double y = *(_Parameters[_Parameters.size()-1]);

	std::cout<<"Joining new and old points"<<"\n";
	int _l = add_segment(*(c->get_gcs_circle().center.x), *(c->get_gcs_circle().center.y), x, y);
	show_values(0);
	SaLine* l2 = (SaLine*)get_shape(_l);
	
	solve();
	show_values(0);

	double* ang = new double(angle);
	_FixedParameters.push_back(ang);

	gcs_sys.addConstraintL2LAngle(l2->get_gcs_line(), l->get_gcs_line(), ang, 1);

	solve();
	show_values(0);

	double p2_x = *(c->get_gcs_circle().center.x) + *(c->get_gcs_circle().rad);
	double p2_y = *(c->get_gcs_circle().center.y);
	
	int p2 = add_point(p2_x, p2_y);

	coincident_point_circle(p2, id2);

	solve();
	show_values(0);

	collinear_point_line(p2, _l);

}
void GCSWrapper::left_of(int id1, int id2)
{
	SaPoint* p = (SaPoint*)get_shape(id1);
	SaLine* l = (SaLine*)get_shape(id2);

	// getting values from point
	double p_x = *(p->get_gcs_point().x);	
	double p_y = *(p->get_gcs_point().y);

	// getting values from line
	double l_x1 = *(l->get_gcs_line().p1.x);
	double l_x2 = *(l->get_gcs_line().p2.x);

	// making new point - point C
	double c_x = *(p->get_gcs_point().x);
	double c_y = *(p->get_gcs_point().y);
	
//	std::cout<<c_x<<"\n";
	int c = add_point(c_x, c_y);

	//fix_line(id2);
	collinear_point_line(c, id2);
	show_values(0);

	solve();

	std::cout<<"Values after first solve"<<"\n";
	show_values(0);

	double x = *(_Parameters[_Parameters.size()-2]);
	double y = *(_Parameters[_Parameters.size()-1]);

	std::cout<<"Joining new and old points"<<"\n";
	//int _l = add_join_segment(p_x, p_y, x, y);
	int _l = add_segment(p_x, p_y, x, y);
	SaLine* l2 = (SaLine*)get_shape(_l);
	SaPoint* c_p = (SaPoint*)get_shape(c);

	gcs_sys.addConstraintP2PCoincident(l2->get_gcs_line().p1, p->get_gcs_point(), 1);
	gcs_sys.addConstraintP2PCoincident(l2->get_gcs_line().p2, c_p->get_gcs_point(), 1);
	
	solve();
	show_values(0);

	//double tmpAng = 90;
	double tmpAng = 1.570796;
	if(!calculate_is_left_of(p, l))
		tmpAng = -1 * (tmpAng);

	double* ang = new double(tmpAng);
	_FixedParameters.push_back(ang);

	std::cout<<"tmpAng: "<<tmpAng<<"\n";

	//gcs_sys.addConstraintL2LAngle(l2->get_gcs_line(), l->get_gcs_line(), ang, 1);
	//gcs_sys.addConstraintL2LAngle(l2->get_gcs_line().p1, l2->get_gcs_line().p2, l->get_gcs_line().p1, l->get_gcs_line().p2, ang, 1);
	gcs_sys.addConstraintL2LAngle(l2->get_gcs_line().p2, l2->get_gcs_line().p1, l->get_gcs_line().p1, l->get_gcs_line().p2, ang, 1);

	solve();

	std::cout<<"Angle after solve: "<<*ang<<"\n";

	//SaPoint* _p = (SaPoint*)get_shape(c);

	//double l_x2 = *(_p->get_gcs_point().x);

	//std::cout<<*_Parameters[_Parameters.size()-4];
	//std::cout<<*_Parameters[_Parameters.size()-3];
	
	//double* d = &(_p->get_gcs_point().x);

	//double l_x2 = (_p->get_gcs_point().x);
	//double l_y2 = *(_p->get_gcs_point().y);


	//int l2 = add_segment(l_x1, l_y1, l_x2, l_y2);
/*
	

	if(p_x >= l_x1 || p_x <= l_x2)
	{
		fix_line(id2);
		collinear_point_line(c, id2);
		gcs_sys.addConstraintL2LAngle(l->get_gcs_line().p1, l->get_gcs_line().p2, 
			l->get_gcs_line().p1, p->get_gcs_point(), ang, 1);
	}
	else
	{
		gcs_sys.addConstraintL2LAngle(l->get_gcs_line().p1, l->get_gcs_line().p2, 
			l->get_gcs_line().p1, p->get_gcs_point(), ang);
	}
	*/
}
Exemple #6
0
static int
read_exif( IMAGE *im, void *data, int data_length )
{
	char *data_copy;

	/* Horrifyingly, some JPEGs have several APP1 sections. We must only
	 * use the first one that starts "Exif.."
	 */
	if( ((char *) data)[0] != 'E' ||
		((char *) data)[1] != 'x' ||
		((char *) data)[2] != 'i' ||
		((char *) data)[3] != 'f' )
		return( 0 );
	if( im_header_get_typeof( im, IM_META_EXIF_NAME ) ) 
		return( 0 );

	/* Always attach a copy of the unparsed exif data.
	 */
	if( !(data_copy = im_malloc( NULL, data_length )) )
		return( -1 );
	memcpy( data_copy, data, data_length );
	if( im_meta_set_blob( im, IM_META_EXIF_NAME, 
		(im_callback_fn) im_free, data_copy, data_length ) ) {
		im_free( data_copy );
		return( -1 );
	}

#ifdef HAVE_EXIF
{
	ExifData *ed;

	if( !(ed = exif_data_new_from_data( data, data_length )) )
		return( -1 );

	if( ed->size > 0 ) {
#ifdef DEBUG_VERBOSE
		show_tags( ed );
		show_values( ed );
#endif /*DEBUG_VERBOSE*/

		/* Attach informational fields for what we find.

			FIXME ... better to have this in the UI layer?

			Or we could attach non-human-readable tags here (int, 
			double etc) and then move the human stuff to the UI 
			layer?

		 */
		exif_data_foreach_content( ed, 
			(ExifDataForeachContentFunc) attach_exif_content, im );

		/* Look for resolution fields and use them to set the VIPS 
		 * xres/yres fields.
		 */
		set_vips_resolution( im, ed );

		attach_thumbnail( im, ed );
	}

	exif_data_free( ed );
}
#endif /*HAVE_EXIF*/

	return( 0 );
}