コード例 #1
0
        /// <summary>
        /// Send command to close the system for frame sending
        /// </summary>
        /// <param name="totalFrame">How many frame you send</param>
        public void StopAcquisition(long totalFrame)
        {
            sendingSocket.EndElaboration(totalFrame);

            FileLogger.AppendText(Path.Combine(Application.persistentDataPath, "CaptureFrame" + DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss") + ".txt"), String.Join("\n", frameAcquired));

            SendJson("http://" + Settings.Settings.Instance.ElaborationServerAddress + ":3000/captureFrame/", "{\"sessionID\":\"" + this.streamID + "\",\"phoneID\":\"" + SystemInfo.deviceUniqueIdentifier + "\",\"captureFrame\":[" + String.Join(",", frameAcquired) + "]}");
        }
コード例 #2
0
        /// <summary>
        /// That function run inside a thread and continue to extract elements from the elaboration queue and send to the sender below, until the elaboration end and there's no more frame to send
        /// </summary>
        private void JpegEncoding()
        {
            while (endElaboration == false)
            {
                Thread.Sleep(10);
                while (requests.TryDequeue(out FrameNode item))
                {
                    try
                    {
                        AdditionalDataSend additionalDataContainer = new AdditionalDataSend()
                        {
                            position       = item.position,
                            rotation       = item.rotation,
                            positionOri    = item.positionOri,
                            rotationOri    = item.rotationOri,
                            focalLength    = item.focalLength,
                            principalPoint = item.principalPoint,
                        };
                        byte[] additionalData = Encoding.UTF8.GetBytes(JsonUtility.ToJson(additionalDataContainer));

                        bool result = false;
                        int  limit  = 0;
                        do
                        {
                            result = sendImage(connectionId, (ulong)item.frameId, item.yBuffer, item.vuBuffer, item.imageWidth, item.imageHeight, additionalData, (uint)additionalData.Length);
                            limit++;
                        }while (result == false && limit < 10);

                        if (result == true)
                        {
                            encodeSuccessFramesList.Add(item.frameId);
                            if (encodeSuccessFramesList.Capacity - 1 >= encodeSuccessFramesList.Count)
                            {
                                StringBuilder logToSave = new StringBuilder();
                                foreach (long element in encodeSuccessFramesList)
                                {
                                    logToSave.AppendLine(element.ToString());
                                }
                                FileLogger.AppendText(this.encodeSuccessFrameFilename, logToSave.ToString());
                                encodeSuccessFramesList.Clear();
                            }
                        }

                        enqueueFrame++;
                        Debug.Log("Elaboration complete, queue size: " + requests.Count);
                        continue;
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("Error during image sending, exception message" + e.ToString());
                        callbackOnFrameSendingError("Error during image sending, exception message" + e.ToString());
                        continue;
                    }
                }
            }
            sendingComplete(connectionId, (ulong)totalFrame);
        }