Recent

Author Topic: Translation from Python to Lazarus  (Read 8677 times)

mpknap

  • Full Member
  • ***
  • Posts: 155
Re: Translation from Python to Lazarus
« Reply #15 on: July 29, 2018, 08:52:28 pm »
I changed the timstamp to the current one, I also changed the size of the image and then nothing. As a friend says only FRAME_CONTENT and TIMESTAMP are required, the rest is not important. Strange, because should work: /

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Translation from Python to Lazarus
« Reply #16 on: July 29, 2018, 11:38:29 pm »
In this case we only need to double check the two needed values. Looking at the Python code you posted above, I see the code skips one or two chars: str(base64_picture)[2:]. That might be it.

1st Edit:
I doubt that it matters, but just in case, the TIMESTAMP numerical value does not need quotation marks, otherwise it would be considered text.

I can't test, yet.

2nd Edit:
It seems that api.credo.science is down.

3rd Edit:
According to their source code, for a detection to be visible it has to fulfill two conditions
1-frame_content is a "valid image":
Code: Python  [Select][+][-]
  1.         frame_content = base64.b64decode(d['frame_content'])
  2.         visible = True
  3.         if (not frame_content) or (not validate_image(frame_content)):
  4.             visible = False
  5.  
  6.         if visible:
  7.             if not r:
  8.                 r = get_redis_connection(write=False)

2-timestamp is later than the user's "start_time":
Code: Python  [Select][+][-]
  1.             start_time = r.zscore(cache.make_key('start_time'), request.user.id)
  2.             if start_time:
  3.                 visible = d['timestamp'] > start_time
  4.             else:
  5.                 visible = False

I think the tests do not fulfill the second condition. They do get stored, but they are not visible.

4th Edit:
I tried again with a recent timestamp value:
Code: Pascal  [Select][+][-]
  1. var
  2.   dt: TDateTime;
  3.   ut: int64;
  4. ...
  5. begin
  6.   dt := Now();
  7.   ut := (DateTimeToUnix(dt)-1)*1000+248;

passing it in the detection stream:
Code: Pascal  [Select][+][-]
  1.     detection:=TStringStream.Create('{"detections": [{"frame_content": ......, "timestamp": '+intToStr(ut)+',....

It is visible, dated 2018-07-30.
« Last Edit: July 30, 2018, 06:24:14 pm by engkin »

mpknap

  • Full Member
  • ***
  • Posts: 155
Re: Translation from Python to Lazarus
« Reply #17 on: July 31, 2018, 06:26:14 am »
Cool!!! I do not know how to thank you. You are fantastic!!! I always try to solve the problems myself but  I struggled with this thread for 3 months, and you did it yourself. Thanks thanks !!!. I also invite you to the CREDO project, there everyone is welcome. Engkin, you are great! :)

 

TinyPortal © 2005-2018