Jump to content

Fabian1648

Members
  • Content Count

    56
  • Joined

  • Last visited

Posts posted by Fabian1648


  1. The problem seems to be due to the fact that the JSON format sent by the server is not compatible with "JSON made in Delphi"!

     

    I found an example that works with code and "JSON that fits" and the JSON has "\" in it that I haven't seen in any example JSON file.

     

    Quote

    const
    response =
    '{"result":["[{\"email\":\"XXX@gmail.com\",\"regid\":\"12312312312312312313213w\"},'+
    '{\"email\":\"YYYY@gmail.com\",\"regid\":\"AAAAAAA\"}]"]}';

    response_bis =
    '{"result":["[{"email":"XXX@gmail.com","regid":"12312312312312312313213w"},'+
    '{"email":"YYYY@gmail.com","regid":"AAAAAAA"}]"]}';

    var
    LResult: TJSONArray;
    LJsonResponse: TJSONObject;
    ja: TJSONArray;
    jv: TJSONValue;

    begin

    LJsonResponse := TJSONObject.ParseJSONValue(response) as TJSONObject;
    LResult := LJsonResponse.GetValue('result') as TJSONArray;
    ja := TJSONObject.ParseJSONValue(LResult.Items[0].Value) as TJSONArray;
    for jv in ja do begin
    memo1.Lines.Add(jv.GetValue<string>('email'));
    memo1.Lines.Add(jv.GetValue<string>('regid'));
    end;
    end;

    The same code processing a JSON from different test servers via REST gives an " Transtyping Error" on the line "LJSONResponse:= TJSONObject.ParseJSONValue(response) as TJSONObject;".

     

    The same code with the "JSON that fits" without the "\" (=response_bis) and we end up with an "Access Violation error" ...

     

    Delphi can parse a JSON file or only a JSON file using a specific Delphi format???


  2. I'm trying to extract data from a REST response with Delphi 10.3.3.

     

    RESTResponse1.ContentType indicates 'application/json'

    RESTResponse1.JSONText give a JSON answer

     

    I use a code coming from the Delphi sample RESTDEMOS

    Quote

    var
    LValues: TJSONArray;
    LJson: TJSONObject;
    LTempSensorName: string;
    LValue: TJsonValue;

     

    Quote

    LJson := RESTRequest.Response.JSONValue as TJSONObject;

    LValues := LJson.Values['values'] as TJSONArray;
    for LValue in LValues do
     begin
     // the sensor values are not objects unfortunately, but arrays of strings
     if (LValue as TJSONArray).Items[0].Value = LTempSensorName then
      begin
       LTemp := StrToInt((LValue as TJSONArray).Items[1].Value) / 100;
      Lbl_Temperature.Caption := Format('%3.0f°F', [LTemp]);
      break;
     end;
    end;

    And it ends with a "Transtyping error" on the first line "LJson := RESTRequest.Response.JSONValue as TJSONObject;".

     

    I can't even retrieve the REST response in a variable of type TJSONObject as TJSONObject;!!!

     

    Does anyone have a sample code that works?

     

    Is this a known bug in version 10.3.3?

     

    Thanks for your answers


  3. Hi,

    In a Android App, I start a CameraComponent with the following code:

    Quote

     if Not Assigned(CameraComponent1) then
      begin
       CameraComponent1 := TCameraComponent.Create(Self);
       CameraComponent1.Kind := TCameraKind.BackCamera;
       CameraComponent1.Quality := TVideoCaptureQuality.MediumQuality;
       CameraComponent1.OnSampleBufferReady := CameraComponent1SampleBufferReady;
       CameraComponent1.Active:=True;
      end;

    When the image capture is done, I stop the camera with the following code:

    Quote

     if Assigned(CameraComponent1) then
      begin
       CameraComponent1.OnSampleBufferReady := nil;
       CameraComponent1.Active := False;

       //CameraComponent1.free;
       FreeAndNil(CameraComponent1);
      end;

    When I want to capture a new picture, the setting "CameraComponent1.Quality := TVideoCaptureQuality.MediumQuality" is no longer applied, the camera use its default setting!

     

    Where is the problem? In my code or in the CameraComponent?


  4. Hi everyone,

     

    Context: Development of an Android app with FMX that requires a smartphone to take a picture of a label and then extract data from the image.

     

    My problem: I use the CameraComponent and it's a pain to get an image that doesn't look like an artistic blur. Big problem with focusing.


    1. As we are used to from Embarcadero, we have a lot of poor documentation. Thanks again to Embarcadero for the help indicating "Embarcadero Technologies has no further information at this time. Please help us document this topic using the Discussion page!"


    2. With a "CameraComponent1.FocusMode := FMX.Media.TFocusMode.AutoFocus" the image is permanently blurred.

     

    3. With a "CameraComponent1.FocusMode:= FMX.Media.TFocusMode.ContinuousAutoFocus", the image is sharp from time to time and the rest of the time, the image returned by the camera shows a focusing that is searching but... not finding the right setting.

     

    4. There doesn't seem to be a Macro mode (which would indicate to the FocusMode that you are limited to close-ups).


    Has anyone experienced this problem before? What would be the best approach to solve this problem? Create a Macro mode? Create a manual focus by indicating a limited area of the image that needs to be "focused"?

     

    Any ideas and opinions are welcome...

     

×