GrabImage in Detect Camera to warm up step 3.1
This commit is contained in:
parent
08e1ba695e
commit
785c8c1881
@ -494,12 +494,9 @@ namespace TBF.Rig.Network.Camera.CJMS11
|
||||
using (NetworkStream stream = client.GetStream())
|
||||
{
|
||||
// Jeden reader pre celé spojenie.
|
||||
var reader = new CameraLineReader(
|
||||
stream,
|
||||
64 * 1024);
|
||||
var reader = new CameraLineReader( stream, 64 * 1024);
|
||||
|
||||
this.ipAddress =
|
||||
IPAddress.Parse(ipAddressParam);
|
||||
this.ipAddress = IPAddress.Parse(ipAddressParam);
|
||||
|
||||
/*
|
||||
* 1. Nastavenie typu kamery
|
||||
@ -600,7 +597,69 @@ namespace TBF.Rig.Network.Camera.CJMS11
|
||||
}
|
||||
|
||||
/*
|
||||
* 3. Status
|
||||
* 3.1 Warm-up grab after type_camera + prepare_camera.
|
||||
*
|
||||
* Hardvér po inicializácii potrebuje vytvoriť aspoň jeden obrázok.
|
||||
* Obrázok pri detekcii nepotrebujeme ukladať ani posielať do UI.
|
||||
*/
|
||||
JmsPacket grabAnswer =
|
||||
await SendCommandAndWaitToAnswerAsync(
|
||||
stream,
|
||||
reader,
|
||||
CommandM.grab_image_,
|
||||
null,
|
||||
10000,
|
||||
CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (grabAnswer == null || grabAnswer.JmsMessage == null || grabAnswer.JmsMessage.Status != MessageStatus.ACK)
|
||||
{
|
||||
throw new IOException( $"Camera initialization grab failed: camera={CameraCfg.Name}, " +
|
||||
$"IP={ipAddressParam}, answer={FormatPacketForLog(grabAnswer)}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ParsedImage initializationImage =
|
||||
grabAnswer.JmsMessage.getImage();
|
||||
|
||||
if (initializationImage == null)
|
||||
{
|
||||
throw new IOException( "Initialization grab returned no parsed image.");
|
||||
}
|
||||
|
||||
if (initializationImage.Encoding != ImageType.BASE_64)
|
||||
{
|
||||
throw new IOException( $"Initialization grab returned unsupported encoding: " + $"{initializationImage.Encoding}");
|
||||
}
|
||||
|
||||
// Vyvolá Base64 dekódovanie a tým overí, že obrázok je platný.
|
||||
using (Image warmUpImage = initializationImage.Image)
|
||||
{
|
||||
if (warmUpImage == null)
|
||||
{
|
||||
throw new IOException(
|
||||
"Initialization grab returned a null image.");
|
||||
}
|
||||
|
||||
log.Debug(
|
||||
$"Initialization image captured: " +
|
||||
$"camera={CameraCfg.Name}, " +
|
||||
$"IP={ipAddressParam}, " +
|
||||
$"size={warmUpImage.Width}x{warmUpImage.Height}");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
throw new IOException( $"Cannot process initialization image: camera={CameraCfg.Name}, " +
|
||||
$"IP={ipAddressParam}, error={exc.Message}", exc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 3.2 Status
|
||||
*/
|
||||
JmsPacket statusAnswer =
|
||||
await SendCommandAndWaitToAnswerAsync(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user