AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Memeber Acces Operators in Delph

Ein Thema von Virchov · begonnen am 23. Mär 2004 · letzter Beitrag vom 24. Mär 2004
Antwort Antwort
Seite 2 von 2     12   
neolithos

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#11

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:15
Ich hätte es wahrscheinlich so formuliert

Delphi-Quellcode:
procedure GetRGB(const prgb: TRGBTRIPLE; var R,G,B: Byte);
begin
  R :=prgb.rgbtRed;
  G :=prgb.rgbtGreen;
  B :=prgb.rgbtBlue;
end;
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat
NicoDE
(Gast)

n/a Beiträge
 
#12

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:23
Zitat von Virchov:
Code:
void GetRGB(
  RGBTRIPLE* prgb,           //Pointer   to the pixel
  BYTE *R, BYTE *G, BYTE *B) //Output:   R, G and B
{
  *R=prgb->rgbtRed;
  *G=prgb->rgbtGreen;
  *B=prgb->rgbtBlue;
}
t *p bedeutet, dass der Parameter p per Referenz (Adresse) an die Funktion übergeben wird (const/var/out p).
*p dereferenziert p und zeigt somit auf den Inhalt von p (p^).
p->v dereferenziert den Struktur-Zeiger p und gibt v zurück (p.val);

Die ganzen De-/Referenzierungen kann man in der Delphi Language einfacher haben:
Delphi-Quellcode:
procedure GetRGB(const RGB: TRGBTriple; out R, G, B: Byte);
begin
  R := RGB.rgbtRed;
  G := RGB.rgbtGreen;
  B := RGB.rgbtBlue;
end;
  Mit Zitat antworten Zitat
neolithos

Registriert seit: 31. Jul 2003
Ort: Dresden
1.386 Beiträge
 
Delphi 7 Architect
 
#13

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:27
@Nico: deswegen (deine Erklärung) ziehe ich eine der Letzten beiden Varianten vor
- ciao neo -
Es gibt niemals dumme Fragen, sondern nur dumme Antworten!
  Mit Zitat antworten Zitat
Virchov

Registriert seit: 15. Mär 2004
Ort: Bäärlin
109 Beiträge
 
#14

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:46

Danke, allerseits!
  Mit Zitat antworten Zitat
Virchov

Registriert seit: 15. Mär 2004
Ort: Bäärlin
109 Beiträge
 
#15

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:54
Scheiße!

Der Compiler sagt "nicht genügend wirkliche Parameter"... Ich habe die Variante von Nico genommen..
  Mit Zitat antworten Zitat
NicoDE
(Gast)

n/a Beiträge
 
#16

Re: Memeber Acces Operators in Delph

  Alt 23. Mär 2004, 18:59
Zitat von Virchov:
Der Compiler sagt "nicht genügend wirkliche Parameter"...
Wie sieht den der Code aus?
  Mit Zitat antworten Zitat
Virchov

Registriert seit: 15. Mär 2004
Ort: Bäärlin
109 Beiträge
 
#17

Re: Memeber Acces Operators in Delph

  Alt 24. Mär 2004, 08:33
Moin, NICO!


Der C -Code sieht ungefähr so aus:

Delphi-Quellcode:
void GetROI_CAL_RGB_VIS(
  RGBTRIPLE* prgb, //Pointer to first pixel
  int cxImage, int cyImage, //Width, Height   of total image
  bool ShowBoundingBox, //if !0, Bounding Box is drawn
  bool ShowROIHistogram, //if !0, ROI Histogram is drawn
  int* roiPosArray,             //Array   containg ROI positions   
  bool* roiMask,                //Mask,pixel[i]   is in ROI if roiMask[i]
  int* minLeft, int* maxLeft, //Vertical Bounding   Box   Scanlines
  int* minTop, int*   maxTop,    //Horizontal Bounding Box Scanlines
  int *numROIPixels, //number of pixels contained in ROI
  bool Check4Rect, //1 = check for ellipse and rectangle, 0 just ellipse
  float fROICutOffLevel //ROI minimal Histogram presence
  )
{
  //declares
  BYTE V;                        //Brightness (V=Max(R,G,B))
  BYTE R,G,B;                     //Red, Green, Blue
  int Histogram[LENBYTE]={0}
;      //Brightness Histogram for this   frame
  const int numPixels = cxImage*cyImage;      //Total   number of pixels
  BYTE roiTreshold;               //Treshold for non-ROI exclusion
  static BYTE roiHistogramMax=0;   //Maximum of times a certain pixel was in ROI
  register idx; //Loop counter for pixels
  static BYTE roiHistogram[STATICMASKSIZE] = {0}; //Times a   pixel was included to ROI because of low brightness
  RGBTRIPLE* prgb0 = prgb;            //Pointer to pixel (0,0)
  const   int   centerCrossRadius =   5;      //Size of the cross   mark representing the center.
  int* YPosArray;                  //Array   containing vertical roi-edges
  int* PosArrayRect; //temp. array containing roi-edges
  static bool OTSUMask[STATICMASKSIZE];   //mask containing !0 for each pix>OTSUthreshold
  static bool EllipseMask[STATICMASKSIZE]; //mask derived from the ellipse approximation
  static bool RectMask[STATICMASKSIZE]; //mask derived from the rectangle approximation
  static int ROIBase=0;               //Contains counter for number of frames   the   roi   is based on

  //allocate memory   for   temporary buffers
  YPosArray   = (int*) calloc(cxImage*2,sizeof(int));
  PosArrayRect = (int*) calloc(cyImage*2,sizeof(int));

  //Flip Bounding Box fictive values, which   are   adjusted later on
  *minTop=cyImage-1,
  *maxTop=0;      
  *minLeft=cxImage-1;
  *maxLeft=0;

  //Build Brightness Histogram of this frame only
  GetBrightnessHistogram(prgb, numPixels, 0, Histogram);
  prgb=prgb0;

  //Get   Treshold for roi and store it in variable roiTreshold
  roiTreshold = (BYTE)(ROISENSE*getTresholdOTSU(Histogram, numPixels));


  //Find roi using treshold and   create a roi/time histogram
  for (prgb=prgb0, idx=0; idx < numPixels; idx++, prgb++){
    //processing in   RGB   space, V-channel = max(R,G,B)

   [color=red] GetRGB(prgb,R,G,B);[/color]
   
        V=GetTripleMax(R,G,B);   
   if ((V > roiTreshold) && (V<=MAXBYTE)){
     //Store the fact that   this pixel was >OSTU   threshold
      // DO NOT use V >= roiThreshold
      // (why? test an image with an image containing only values of 0 and 255)
     OTSUMask[idx]=1;
     if (roiHistogram[idx] < MAXBYTE){
      //Raise   number of times this pixel was included   in ROI,   with a max of MAXBYTE
      roiHistogram[idx]++;

      if (roiHistogram[idx] > roiHistogramMax)
         roiHistogramMax = roiHistogram[idx];
     }
 // roiHistogram<MAXBYTE
   }
   else
      {
      OTSUMask[idx]=0;
      // added by BF in order to be able to remove errand pixels again from roi:
      if (roiHistogram[idx] > 0)
         roiHistogram[idx]--;
      }
 // else

     //Set   this pixel to 1   in the mask   if they   are   more then %   of the times
     //detected as   higher than   the   treshold
     //else added by BF, Jul 11, 2003
     if ((roiHistogram[idx] / (float)roiHistogramMax) > fROICutOffLevel)
        roiMask[idx]   = 1;
     else
        roiMask[idx]   = 0;
     } // for prgb,idx
  prgb = prgb0;
  ROIBase++;

....Jetzt ist folgendes Problem aufgetreten. Das Parameter "RGB" habe ich in PRGB umbenannt, da RGB so eine Art reserviertes Wort in Delphi ist. Nun sagt der Compiler das hier:

Incompatible Typen: Tagrgbtriple und "prgbtriple"

ps Den Code habe ich schon übersetzt in D., nur poste ich den hier in C (ausser dieser rotmarkierten Zeile) übersichtlichkeitshalber

Danke!
  Mit Zitat antworten Zitat
Virchov

Registriert seit: 15. Mär 2004
Ort: Bäärlin
109 Beiträge
 
#18

Re: Memeber Acces Operators in Delph

  Alt 24. Mär 2004, 08:48
aber so gin es!! Wäre es richtig so?


   GetRGB (PRGB^,R,G,B); ps Ich habe Dereferenzierung von PRGB vorgenommen , also statt PRGB, PRGB^ rinjeschrieben.

pps Nochmal: GetRgb ist früher folgendermaßen deklariert worden:


Delphi-Quellcode:


procedure GetRGB(
 PRGB: TRGBTRIPLE;          //Pointer   to the pixel
   var R,G,B: BYTE); //Output:   R, G and B

  begin
  R:=prgb.rgbtRed; ;
  G:=prgb.rgbtGreen;
  B:=prgb.rgbtBlue;
end;
Also, liege ich da richtig oder das mit der Deref. ist verkehrt?
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz