GetRGBPixelAt
TVideoGrabber.GetRGBPixelAt |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns the RGB value of the specified pixel.
Declaration
function GetRGBPixelAt (x: LongInt; y: LongInt): Longint;
int GetRGBPixelAt(int x, int y);
Function GetRGBPixelAt (x as Long, y as Long) as Long
Description
Used to retrieve the RGB value of the specified pixel at the (x, y) location in the current video frame.
Note: this function must be invoked from one of the OnFrameOverlayUsing... events (e.g. from the OnFrameOverlayUsingDC event).
This function returns the RGB value at the x, y location on the video frame, with:
x between 0 and (VideoSourceWidth -1)
and
y between 0 and <= (VideoSourceHeight - 1)
You can extract each pixel color from the value returned by using the following sample code:
DELPHI
procedure TfrmMainForm.VideoGrabberFrameOverlayUsingDC(Sender: TObject;
Dc: HDC; FrameNumber: Cardinal; FrameTime: Int64; FrameId: Integer);
var
RGBValue: LongInt;
R, G, B: LongInt;
x, y: LongInt;
begin
x := 10; // e.g. row 10
y := 15; // and column 15
RGBValue := VideoGrabber.GetRGBPixelAt (x, y);
R := RGBValue and $FF;
G := (RGBValue shr 8) and $FF;
B := (RGBValue shr 16) and $FF;
end;
C++
void __fastcall TfrmMainForm::VideoGrabberFrameOverlayUsingDC(
TObject *Sender, HDC Dc, DWORD FrameNumber, Int64 FrameTime,
int FrameId)
int RGBValue, R, G, B, x, y;
x = 10; // e.g. row 10
y = 15; // and column 15
RGBValue = VideoGrabber->GetRGBPixelAt (x, y);
R = RGBValue && 0xFF;
G = (RGBValue >> 8) && 0xFF;
B = (RGBValue >> 16) && 0xFF;
C#
private void axVideoGrabberNET1_OnFrameOverlayUsingDC(object sender, Axvidgrab_NET.IVideoGrabberNETEvents_OnFrameOverlayUsingDCEvent e)
...
Color RGBColor = System.Drawing.Color.FromArgb (axVideoGrabberNET1.GetRGBPixelAt(10, 15));
textBoxR.Text = RGBColor.R.ToString();
textBoxG.Text = RGBColor.G.ToString();
textBoxB.Text = RGBColor.B.ToString();
...
See Also
Image overlays GetPixelsDistance ImageOverlay_AlphaBlend ImageOverlay_AlphaBlendValue ImageOverlay_Height ImageOverlay_LeftLocation ImageOverlay_TopLocation ImageOverlay_Transparent ImageOverlay_TransparentColorValue ImageOverlay_UseTransparentColor ImageOverlay_Width ImageOverlayEnabled ImageOverlaySelector SetImageOverlay_AlphaBlend SetImageOverlay_AlphaBlendValue SetImageOverlay_ChromaKey SetImageOverlay_ChromaKeyLeewayPercent SetImageOverlay_ChromaKeyRGBColor SetImageOverlay_Enabled SetImageOverlay_Height SetImageOverlay_LeftLocation SetImageOverlay_RotationAngle SetImageOverlay_StretchToVideoSize SetImageOverlay_TargetDisplay SetImageOverlay_TopLocation SetImageOverlay_Transparent SetImageOverlay_TransparentColorValue SetImageOverlay_UseTransparentColor SetImageOverlay_Width SetImageOverlayFromBMPFile SetImageOverlayFromHBitmap SetImageOverlayFromHBitmap2 SetImageOverlayFromImageFile SetImageOverlayFromImageFile2 SetImageOverlayFromJPEGFile SetImageOverlayFromTBitmap SetImageOverlayFromTBitmap2 SetImageOverlayFromTImage SetImageOverlayFromTImage2