HALCON Reference Manual 10.0.2
Table of Contents / System / Database ClassesClassesClasses | | | Operators

count_relationcount_relationcount_relationCountRelationCountRelation (Operator)

Name

count_relationcount_relationcount_relationCountRelationCountRelation — Number of entries in the HALCON database.

Signature

count_relation( : : RelationName : NumOfTuples)

Herror count_relation(const char* RelationName, Hlong* NumOfTuples)

Herror T_count_relation(const Htuple RelationName, Htuple* NumOfTuples)

Herror count_relation(const HTuple& RelationName, Hlong* NumOfTuples)

void HOperatorSetX.CountRelation(
[in] VARIANT RelationName, [out] VARIANT* NumOfTuples)

Hlong HSystemX.CountRelation([in] BSTR RelationName)

static void HOperatorSet.CountRelation(HTuple relationName, out HTuple numOfTuples)

static int HSystem.CountRelation(string relationName)

Description

The operator count_relationcount_relationcount_relationCountRelationCountRelation counts the number of entries in one of the five relations of the HALCON database since the database was swiched on by the value 'database'"database""database""database""database" of the operator set_systemset_systemset_systemSetSystemSetSystem. If the database was disabled, the number 0 will be returned and a warning will be raised if value 'do_low_error'"do_low_error""do_low_error""do_low_error""do_low_error" of operator set_systemset_systemset_systemSetSystemSetSystem is enabled. The state of the database can be queried by the parameter value 'database'"database""database""database""database" of the operator get_systemget_systemget_systemGetSystemGetSystem.

The HALCON database is organized in five tables called relations. The single entries in this relations are called tuples, generally (not to mix up with HALCON tuples naming object arrays). If enabled, the HALCON database contains the basic relations for region-data, image-matrices and XLDs, as well as the container relations for HALCON objects and HALCON tuples. The HALCON objects region and image are constructed from elements from these two relations: a region consists of a pointer to a tuple in the region-data relation. An image consists also of a pointer to a tuple in the region-data relation (like a region) and additionally of one or more pointers to tuples in the matrix relation. If there is more than one matrix pointer, the image is called a multi-channel image.

Both regions and images are called objects. A region can be considered as the special case of an iconic object having no image matrixes. For reasons of an efficient memory managment, the tuples of the region-data relation and the image-matrix relation will be used by different objects together. Therefore there may be for example more images than image matrices. Only the two lowlevel relations are of relevance to the memory consumption. Image objects (regions as well as images) consist only of references on region and matrix data and therefore only need a couple of bytes of memory.

Possible values for RelationNameRelationNameRelationNameRelationNamerelationName:

'image':

Image matrices. One matrix may also be the component of more than one image (no redundant storage).

'region':

Regions (the full and the empty region are always available). One region may of course also be the component of more than one image object (no redundant storage).

'XLD':

eXtended Line Description: Contours, Polygons, paralles, lines, etc. XLD data types don't have gray values and are stored with subpixel accuracy.

'object':

Iconic objects. Composed of a region (called region) and optionally image matrices (called image).

'tuple':

In the compact mode, tuples of iconic objects are stored as a surrogate in this relation. Instead of working with the individual object keys, only this tuple key is used. It depends on the host language, whether the objects are passed individually (e.g., C++) or as tuples (e.g., C).

Certain database objects will be created already by the operator reset_obj_dbreset_obj_dbreset_obj_dbResetObjDbResetObjDb and therefore have to be available all the time (the undefined gray value component, the objects 'full' (FULL_REGION in HALCON/C) and 'empty' (EMPTY_REGION in HALCON/C) as well as the herein included empty and full region). By calling get_channel_infoget_channel_infoget_channel_infoGetChannelInfoGetChannelInfo, the operator therefore appears correspondingly also as 'creator' of the full and empty region. The procedure can be used for example to check the completeness of the clear_objclear_objclear_objClearObjClearObj operation.

Parallelization

Parameters

RelationNameRelationNameRelationNameRelationNamerelationName (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Relation of interest of the HALCON database.

Default value: 'object' "object" "object" "object" "object"

List of values: 'image'"image""image""image""image", 'region'"region""region""region""region", 'XLD'"XLD""XLD""XLD""XLD", 'object'"object""object""object""object", 'tuple'"tuple""tuple""tuple""tuple"

NumOfTuplesNumOfTuplesNumOfTuplesNumOfTuplesnumOfTuples (output_control)  integer HTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong)

Number of tuples in the relation.

Example (HDevelop)

reset_obj_db(512,512,3)
count_relation('image',I1)
count_relation('region',R1)
count_relation('XLD',X1)
count_relation('object',O1)
count_relation('tuple',T1)
read_image(X,'monkey')
count_relation('image',I2)
count_relation('region',R2)
count_relation('XLD',X2)
count_relation('object',O2)
count_relation('tuple',T2)

*
* Result: I1 = 1  (undefined image)
       * R1 = 2  (full and empty region)
       * X1 = 0  (no XLD data)
       * O1 = 2  (full and empty objects)
       * T1 = 0  (always 0 in the normal mode )

       * I2 = 2  (additionally the image 'monkey')
       * R2 = 2  (read_image uses the full region)
       * X2 = 0  (no XLD data)
       * O2 = 3  (additionally the image object X)
       * T2 = 0.

Example (C)

reset_obj_db(512,512,3) ;
count_relation("image",&I1) ;
count_relation("region",&R1) ;
count_relation("XLD",&X1) ;
count_relation("object",&O1) ;
count_relation("tuple",&T1) ;
read_image(&X,"monkey") ;
count_relation("image",&I2) ;
count_relation("region",&R2) ;
count_relation("XLD",&X2) ;
count_relation("object",&O2) ;
count_relation("tuple",&T2) ;

/*
Result:   I1 = 1  (undefined image)
          R1 = 2  (full and empty region)
          X1 = 0  (no XLD data)
          O1 = 2  (full and empty objects)
          T1 = 0  (always 0 in the normal mode)

          I2 = 2  (additionally the image 'monkey')
          R2 = 2  (read_image uses the full region)
          X2 = 0  (no XLD data)
          O2 = 3  (additionally the image object X)
          T2 = 0.
*/

Example (HDevelop)

reset_obj_db(512,512,3)
count_relation('image',I1)
count_relation('region',R1)
count_relation('XLD',X1)
count_relation('object',O1)
count_relation('tuple',T1)
read_image(X,'monkey')
count_relation('image',I2)
count_relation('region',R2)
count_relation('XLD',X2)
count_relation('object',O2)
count_relation('tuple',T2)

*
* Result: I1 = 1  (undefined image)
       * R1 = 2  (full and empty region)
       * X1 = 0  (no XLD data)
       * O1 = 2  (full and empty objects)
       * T1 = 0  (always 0 in the normal mode )

       * I2 = 2  (additionally the image 'monkey')
       * R2 = 2  (read_image uses the full region)
       * X2 = 0  (no XLD data)
       * O2 = 3  (additionally the image object X)
       * T2 = 0.

Example (HDevelop)

reset_obj_db(512,512,3)
count_relation('image',I1)
count_relation('region',R1)
count_relation('XLD',X1)
count_relation('object',O1)
count_relation('tuple',T1)
read_image(X,'monkey')
count_relation('image',I2)
count_relation('region',R2)
count_relation('XLD',X2)
count_relation('object',O2)
count_relation('tuple',T2)

*
* Result: I1 = 1  (undefined image)
       * R1 = 2  (full and empty region)
       * X1 = 0  (no XLD data)
       * O1 = 2  (full and empty objects)
       * T1 = 0  (always 0 in the normal mode )

       * I2 = 2  (additionally the image 'monkey')
       * R2 = 2  (read_image uses the full region)
       * X2 = 0  (no XLD data)
       * O2 = 3  (additionally the image object X)
       * T2 = 0.

Example (HDevelop)

reset_obj_db(512,512,3)
count_relation('image',I1)
count_relation('region',R1)
count_relation('XLD',X1)
count_relation('object',O1)
count_relation('tuple',T1)
read_image(X,'monkey')
count_relation('image',I2)
count_relation('region',R2)
count_relation('XLD',X2)
count_relation('object',O2)
count_relation('tuple',T2)

*
* Result: I1 = 1  (undefined image)
       * R1 = 2  (full and empty region)
       * X1 = 0  (no XLD data)
       * O1 = 2  (full and empty objects)
       * T1 = 0  (always 0 in the normal mode )

       * I2 = 2  (additionally the image 'monkey')
       * R2 = 2  (read_image uses the full region)
       * X2 = 0  (no XLD data)
       * O2 = 3  (additionally the image object X)
       * T2 = 0.

Result

If the parameter is correct, the operator count_relationcount_relationcount_relationCountRelationCountRelation returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Possible Predecessors

reset_obj_dbreset_obj_dbreset_obj_dbResetObjDbResetObjDb

See also

clear_objclear_objclear_objClearObjClearObj

Module

Foundation


Table of Contents / System / Database ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH