0

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

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

使用 PlayMemories Android 应用程序时(版本 5.7.0,西班牙语。Android V. 6.0.1 Asus Zenphone 2 Laser (ASUS_Z00TD) *以前可以正常使用 Playmemories)

- 相机连接“正常” - 没有实时取景可用(带有叠加控件的黑屏) - 从 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 的响应:

采取行动

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

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

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

等待拍照

OK{"error":[40403,"Not Finished"],"id":1}(拍照后继续)

或者

OK{"error":[1,""],"id":1}(在没有拍照的情况下,上面和这个之间看起来有点随机)

获取事件

使用:\"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 started Liveview 但是没有答案。谢谢你们!!!

4

0 回答 0