Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Daten in Datei speichern

Empfohlene Antworten

Veröffentlicht

Hallo!

Ich würde gerne Daten, die über eine Funktion ausgelesen werden in eine Text Datei speichern und dann diese über das Programm öffnen.

Die Funktion hat folgenden Code:

void ProcessImage(CyUserBuffer &userBuffer, CSpyder3GigEInterface *camera)

{

// Process image

unsigned char *tempBuffer = userBuffer.GetBuffer();

long max = -1, maxX, maxY;

long min = 0x7fffffff, minX, minY; //

unsigned long width=0;

unsigned long height=0;

unsigned long pixelWidth =0;

camera->GetSizeX(width);

camera->GetSizeY(height);

camera->GetPixelByteSize(pixelWidth);

for (int r = 0; r<(int)height; r++)

{

for (int c = 0; c< (int)width ; c++)

{

int value;

if ( pixelWidth == 1)

value = (int)(tempBuffer[ r*width+c]);

else

{

unsigned short indx =(r*width+c) * pixelWidth ;

value = tempBuffer[ indx+1 ]&0x0f;

value = value<<8;

value |= tempBuffer[indx];

}

if ( value > max )

{

max =value;

maxX = c;

maxY = r;

}

if ( value < min )

{

min = value;

minX = c;

minY = r;

}

if ( r%100 == 0)

printf("%d,", value);

}

if ( r%100 == 0)

printf("\n");

}

printf( "Maximum Value(%d, %d) = %d\n",maxX,maxY, max);

printf( "Minimum Value(%d, %d) = %d\n",minX,minY, min);

}

Ich möchte als die Werte, die über printf erzeugt werden, in diese Datei schreiben.

Wie geht das?

Kann mir jemand einen Beispiel Code dazu schicken, wenn das möglich ist?

Wäre super, wenn ich ne Antwort bekomme. Ist echt wichtig.

Das ist der Code:

void ProcessImage(CyUserBuffer &userBuffer, CSpyder3GigEInterface *camera)

{

// Process image

unsigned char *tempBuffer = userBuffer.GetBuffer();

long max = -1, maxX, maxY; 

long min = 0x7fffffff, minX, minY; //

unsigned long width=0;

unsigned long height=0;

unsigned long pixelWidth =0;

camera->GetSizeX(width);

camera->GetSizeY(height);

camera->GetPixelByteSize(pixelWidth);

	for (int r = 0; r<(int)height; r++)

	{

		for (int c = 0; c< (int)width ; c++)

		{

			int value;

			if ( pixelWidth == 1)

				value = (int)(tempBuffer[ r*width+c]);

			else

			{

				unsigned short indx =(r*width+c) * pixelWidth ;

				value = tempBuffer[ indx+1 ]&0x0f;

				value = value<<8;

				value |= tempBuffer[indx];

			}

			if ( value > max )

			{

				max =value;

				maxX = c;

				maxY = r;

			}

			if ( value < min )

			{

				min = value;

				minX = c;

				minY = r;

			}

			if ( r%100 == 0)

				printf("%d,", value); // Was soll das?

		} // next c

		if ( r%100 == 0)

		printf("\n");

	} // next r

printf( "Maximum Value(%d, %d) = %d\n",maxX,maxY, max);

printf( "Minimum Value(%d, %d) = %d\n",minX,minY, min);

}

Was soll die markierte Stelle tun?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.