C#上的Sony远程应用程序。尝试实时视频后被困

时间:2016-11-01 08:16:49

标签: c# sony sony-camera-api

所以这是我的问题。我正在尝试使用索尼远程摄像头API SDK作为使用C#在Visual Studio中开发简单程序并控制SDCQX-10的指南。我试图使用kz-remote应用程序...但无法解决它。所以我决定通过使用网络套接字完成它。 一开始很棒,但过了一段时间我决定试一试现场观看......然后一切都崩溃了。我的意思是,通过一切,相机停止响应。我设法让镜头“关闭并再次打开(缩回)”,取出电池并再次插入并打开相机,但是当试图拍照时相机再次停止响应。 好的,经过一些解决方法后,这些症状(相机更新到V3.0固件):

- 相机正常开启,通过手动控制可以放大和缩小 - 按下快门时需要一段时间才能拍出“拍照”声(虽然没有拍照) - 听到“拍照”声后,红色LED指示灯(存取指示灯)一直亮着(ON) - 按下快门后,相机不响应(禁用放大/缩小,快门也不响应) - 关闭镜头时不会缩回

使用PlayMemories Android应用程序(版本5.7.0,西班牙语.Android V. 6.0.1华硕Zenphone 2激光(ASUS_Z00TD)*以前与Playmemories一起正常工作)

- 相机连接“正常” - 没有实时视图(带控件叠加的黑屏) -Zoom输入/输出来自Android设备 - 一段时间后会显示“无法获取直接可视化图像”的内容 - 当按下遥控快门时,也会发生上述手动快门的所有症状。

最后,我尝试检查使用该程序时发生了什么: 我在按钮上使用以下代码连接相机(SDDP以发现相机并检索信息)

private void button2_Click(object sender, EventArgs e)
    {
        IPEndPoint LocalEndPoint = new IPEndPoint(IPAddress.Any, 60000);
        IPEndPoint MulticastEndPoint = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 1900);

        Socket UdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        UdpSocket.Bind(LocalEndPoint);

        textBox1.AppendText("UDP-Socket setup done...\r\n");

        string SearchString = "M-SEARCH * HTTP/1.1\r\nHOST:239.255.255.250:1900\r\nMAN:\"ssdp:discover\"\r\nST:urn:schemas-sony-com:service:ScalarWebAPI:1\r\nMX:3\r\n\r\n";

        UdpSocket.SendTo(Encoding.UTF8.GetBytes(SearchString), SocketFlags.None, MulticastEndPoint);

        textBox1.AppendText("M-Search sent...\r\n");

        byte[] ReceiveBuffer = new byte[64000];

        int ReceivedBytes = 0;

        while (true)
        {
            if (UdpSocket.Available > 0)
            {
                ReceivedBytes = UdpSocket.Receive(ReceiveBuffer, SocketFlags.None);

                if (ReceivedBytes > 0)
                {
                    textBox1.AppendText(Encoding.UTF8.GetString(ReceiveBuffer, 0, ReceivedBytes));
                }
                break;
            }
        }
    }

之后我得到了这个回复:

HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
EXT: 
LOCATION: http://10.0.0.1:64321/DmsRmtDesc.xml
SERVER: UPnP/1.0 SonyImagingDevice/1.0
ST: urn:schemas-sony-com:service:ScalarWebAPI:1
USN: uuid:00000000-0005-0010-8000-1c994c0c5152::urn:schemas-sony-com:service:ScalarWebAPI:1
X-AV-Physical-Unit-Info: pa=""; pl=;
X-AV-Server-Info: av=5.0; hn=""; cn="Sony Corporation"; mn="SonyImagingDevice"; mv="1.0";

我在另一个按钮上使用此脚本以测试不同的功能:

private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a request using a URL that can receive a post. 
                WebRequest request = WebRequest.Create("http://10.0.0.1:10000/sony/camera ");
                // Set the Method property of the request to POST.
                request.Method = "POST";
                // Create POST data and convert it to a byte array.
                string postData = "{\"method\": \""+textBox2.Text+"\",\"params\": [],\"id\": 1,\"version\": \"1.0\"}";

                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/x-www-form-urlencoded";
                // Set the ContentLength property of the WebRequest.
                request.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = request.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                textBox1.AppendText(((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                textBox1.AppendText(responseFromServer);
                var fot = responseFromServer.Substring(20).Split('\"').FirstOrDefault();
                //textBox2.AppendText(fot);
                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();
                webBrowser1.Url = new Uri(fot);
                // Follow intruction to try to visualize the image
                //var client = new WebClient();
                //client.DownloadFile(webBrowser1.Url, @"c:/foto.jpg");
                //using (MemoryStream mem = new MemoryStream(dat))
                //{
                //    using (var im = Image.FromStream(mem))
                //    {
                //        pictureBox1.Image = (Bitmap) im;
                //    }
                //}
                //pictureBox1.Image = Bitmap.FromFile(@"c:/foto.jpg");
            }
            catch (Exception ex)
            {
            }
        }

拍摄照片很好,我评论了最后几行,我用它们来检索图片(我将它们留在那里,因为在那之前它工作正常,拍照并可视化)

所以,我在崩溃之前没有数据(对我来说很遗憾)......但之后,这里有一些API的回复:

actTakePicture

OK{"error":[40403,"Long shooting"],"id":1}

然后(第二次按下时再打开)

OK{"error":[5,""],"id":1}

awaitTakePicture

OK{"error":[40403,"Not Finished"],"id":1}(拍摄照片后保持此状态)

OK{"error":[1,""],"id":1}(在没有拍照的情况下,上面和此之间似乎有点随机)

getEvent

使用:\"params\": [false]

OK{"id":1,"result":[{"names":["getMethodTypes","getAvailableApiList","setShootMode","getShootMode","getSupportedShootMode","getAvailableShootMode","setSelfTimer","getSelfTimer","getSupportedSelfTimer","getAvailableSelfTimer","setPostviewImageSize","getPostviewImageSize","getSupportedPostviewImageSize","getAvailablePostviewImageSize","startLiveview","stopLiveview","actTakePicture","startMovieRec","stopMovieRec","awaitTakePicture","actZoom","setExposureMode","getExposureMode","getSupportedExposureMode","getAvailableExposureMode","setBeepMode","getBeepMode","getSupportedBeepMode","getAvailableBeepMode","setCameraFunction","getCameraFunction","getSupportedCameraFunction","getAvailableCameraFunction","setStillSize","getStillSize","getSupportedStillSize","getAvailableStillSize","actFormatStorage","getStorageInformation","setTouchAFPosition","cancelTouchAFPosition","getTouchAFPosition","getSupportedExposureCompensation","getSupportedWhiteBalance","getSupportedIsoSpeedRate","actHalfPressShutter","cancelHalfPressShutter","getApplicationInfo","getVersions","getEvent"],"type":"availableApiList"},{"cameraStatus":"IDLE","type":"cameraStatus"},{"type":"zoomInformation","zoomIndexCurrentBox":0,"zoomNumberBox":1,"zoomPosition":0,"zoomPositionCurrentBox":0},{"liveviewStatus":true,"type":"liveviewStatus"},{"liveviewOrientation":"0","type":"liveviewOrientation"},[{"takePictureUrl":[],"type":"takePicture"}],[],{"triggeredError":[],"type":"triggeredError"},{"motionRecognition":"None","sceneRecognition":"None","steadyRecognition":"None","type":"sceneRecognition"},{"formatResult":"","type":"formatStatus"},[{"numberOfRecordableImages":1228,"recordTarget":true,"recordableTime":-1,"storageDescription":"Storage Media","storageID":"Memory Card 1","type":"storageInformation"}],{"beepModeCandidates":["Shutter Only","On","Off"],"currentBeepMode":"On","type":"beepMode"},{"cameraFunctionCandidates":["Remote Shooting","Contents Transfer"],"currentCameraFunction":"Remote Shooting","type":"cameraFunction"},null,{"checkAvailability":true,"currentAspect":"4:3","currentSize":"18M","type":"stillSize"},{"cameraFunctionResult":"","type":"cameraFunctionResult"},null,null,{"currentExposureMode":"Intelligent Auto","exposureModeCandidates":["Intelligent Auto","Superior Auto","Program Auto"],"type":"exposureMode"},{"currentPostviewImageSize":"2M","postviewImageSizeCandidates":["2M","Original"],"type":"postviewImageSize"},{"currentSelfTimer":0,"selfTimerCandidates":[0,2,10],"type":"selfTimer"},{"currentShootMode":"still","shootModeCandidates":["still","movie"],"type":"shootMode"},null,null,null,null,null,null,null,null,null,null,null,null,{"currentSet":false,"currentTouchCoordinates":[],"type":"touchAFPosition"}]}

嗯,我真的希望这是足够的信息。而且我真的希望有人可以帮我这个!!!! 我找到的一个类似的主题是: Sony RemoteAPI delays after starting Liveview 但没有答案。 谢谢大家!!!

0 个答案:

没有答案