问题
So here is my question. I am trying to use the sony remote camera API SDK as a guide for developing a simple program in Visual studio using C# and controlling a SDCQX-10. I tried to use the kz-remote app... but couldn't get around with it. So I decided to get it done by using network sockets. It was wonderful, at the beginning, but after a while I decided to give it a try to liveviewing... Then everything crashed. I mean, by everything, The camera stopped responding. I managed to get the lenses "closed and opened again (retract)" by removing the battery and inserting it again and switching the camera on, but then, when trying to take a picture the camera stopped responding again. OK so, after some workaround here are the symptoms (camera is Updated to V3.0 firmware):
-The camera turns on normally, by manual control you can zoom in and out -When the shutter is pressed it takes a while for it to make the "take picture" sound (Although no picture is taken) -After the "Take picture" sound is heard, the red led indicator (Access lamp) keeps lit (ON) -After the shutter is pressed, the camera does not respond (The zoom in/out is disabled, shutter does not respond either) -When turning off the lens doesn't retract
When using the PlayMemories Android App (Version 5.7.0, spanish. Android V. 6.0.1 Asus Zenphone 2 Laser (ASUS_Z00TD) *Previously working OK with Playmemories)
-The camera connects "normally" -No liveview is available (black screen with controls superposed) -Zoom in/out works from the android device -Something that will translate as "Cannot obtain direct visualization image" is displayed after some time -When remote shutter is pressed all the symptoms above described for the manual shutter happen as well.
Finally, I tried to check what was happening when using the program: I use the following code on a button to connect the camera (SDDP to discover the camera and retrieve the information)
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;
}
}
}
After which I get this response:
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";
I used this script on another button in order to test different functions:
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)
{
}
}
It worked fine to take pictures, I commented the few last lines, I used them to retrieve the picture (I'm leaving them there because until then it was working OK, for taking the picture and visualizing it)
SO, i have no data before the crash (Shame on me)... But after, here are some responses for the API:
actTakePicture
OK{"error":[40403,"Long shooting"],"id":1}
then (When pressed a second time and on)
OK{"error":[5,""],"id":1}
awaitTakePicture
OK{"error":[40403,"Not Finished"],"id":1}
(Keeps on this after taking the Picture)
or
OK{"error":[1,""],"id":1}
(It appears a bit random in between the above and this one when no picture has been taken)
getEvent
using: \"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"}]}
Well, I really hope that is enough information. And I really hope somebody can help me with this!!!! A similar thread I found is: Sony RemoteAPI delays after starting Liveview But there were no answers. Thank you all!!!
来源:https://stackoverflow.com/questions/40356310/sony-remote-app-on-c-stucked-after-trying-liveview