cjbruce's Forum Posts

  • I am trying to read and process pixel data from the camera as quickly as possible. Using the UserMedia and DrawingCanvas plugins I can retrieve pixel data at a maximum stable rate of around 5 fps. The Aruco library can process Aruco markers at 60 fps. https://github.com/damianofalcioni/js-aruco2

    Event sheets are regularly taking 200 ms to retrieve and process the camera pixel data, while the getusermedia_ARUCO.html sample project can do the same thing in well under 16 ms.

    Ashley Why the difference? Why is performing the same task in the event sheets so much slower?

    Is there a quick and easy way to speed up the process? I would love to recreate the process in Construct, but I need 60 fps for my application.

    Tagged:

  • Hi all,

    I'm looking to build an app based on a pure javascript implementation of OpenCV. I am looking to import a legacy javascript file called "cv.js" into main.js.

    What do I need to do in cv.js and what do I need to add in main.js to get this working correctly?

    Thank you for your help!

    Here are the first few lines of the legacy script:

    /* References: - "OpenCV: Open Computer Vision Library" http://sourceforge.net/projects/opencvlibrary/ - "Stack Blur: Fast But Goodlooking" http://incubator.quasimondo.com/processing/fast_blur_deluxe.php */

    var CV = CV || {};

    this.CV = CV;

    CV.Image = function(width, height, data){ this.width = width || 0; this.height = height || 0; this.data = data || []; };

    CV.grayscale = function(imageSrc, imageDst){ var src = imageSrc.data, dst = imageDst.data, len = src.length, i = 0, j = 0;

    for (; i < len; i += 4){ dst[j ++] = (src * 0.299 + src[i + 1] * 0.587 + src[i + 2] * 0.114 + 0.5) & 0xff; }

    Tagged:

  • I have some old work from 2015 that needs to be ported to Construct 3. Does anyone know if Construct 2 will run on a mac using Parallels?

    If not, is there any other way to make it work on an M1/M2 mac? I would rather do this than try to dig up an old Windows laptop and pray that it still works.

    Tagged:

  • PROBLEM #1 (SOLVED) - MAKING PROMISES WORK IN BROWSER -> EXECUTE JAVASCRIPT

    I'm now struggling with integrating with the existing API built for my client. The API relies almost entirely on javascript promises. I have found that promises don't work directly in Browser -> Execute Javascript() because promises don't work with eval(), and that is the basis for the Construct event.

    I found that I have been able to work around this by wrapping the promise in an anonymous function, casting the MOPusername promise as a new MOPusername object:

    Browser -> Execute Javascript "MOPusername = Service.GetUser().then(GetUserResponse => { document.getElementById(""getUserResponse"").value = GetUserResponse.Username;

    //GetUserResponse.IsGuest

    //GetUserResponse.Username

    return GetUserResponse;

    //if(ErrorOccurred (GetUserResponse)) {

    // abort

    //}

    }).then(result => {return result.Username});"

    Browser -> Execute Javascript "(async () => {MOPusername = await MOPusername})()"

    PROBLEM #2 - MAKING .then() CALL c2_callFunction() IN BROWSER -> EXECUTE JAVASCRIPT

    The next problem is proving to be beyond me. For some reason I can't get c2_callFunction() to work within a promise when called from BROWSER -> EXECUTE JAVASCRIPT.

    The following works when typed into the console. The expected result is .Success = 1:

    When run from inside Construct 3, however, it gives a different result of .Success = 0:

    Ashley, is there anything going on that would wait for the promise to be resolved in the console before c3_function("setUserResult") is called, but NOT wait for the promise when c3_function("setUserResult") is called inside a Browser -> Execute Javascript within Construct 3?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • EDIT - It looks like

    window.c3_callFunction("getUser")

    exists in Construct 3 as well. I should be able to write a single event sheet that works with both C2 and C3.

    Ashley Is there any possibility that c3_callFunction will be removed in future releases?

  • I have a large back catalog of Construct 2 and Construct 3 projects that I am looking to integrate with a customer's database backend using javascript. I am looking for a way to trigger a Construct event using javascript.

    For Construct 2 I found the following in the manual:

    "Javascript integration

    It is strongly recommended to use the Javascript plugin SDK to integrate Javascript code with Construct 2. However it is possible to trigger a function in the Function object from Javascript code using the following function:

    if (c2_callFunction)

    c2_callFunction("name", ["param1", "param2"]);

    Note if the Function object is not included in a project, the c2_callFunction function will not exist, so the if check is necessary before using it. The function with the given "name" is triggered synchronously. Parameters are optional and can be omitted, but must be provided as an array in the second argument, and parameters may only be string or number values (any other types will return as 0 in Construct 2). The c2_callFunction method also returns the return value set in Construct 2 (if any), and also can only return a string or number."

    I haven't found an equivalent in Construct 3.

    I would like to create a single event sheet template for both C2 and C3 that I can use to integrate with my client's javascript functions. I originally tried creating an HTML button in Construct, then modifying the "value" of the button and reading it as "button.text" in the event sheet, but this didn't work because the "text" property in Construct 3 is not changed when its HTML element "value" is modified in javascript.

    Is there a way to trigger an event from javascript in both Construct 2 and Construct 3 without repeatedly running Browser.ExecJS?

    I would prefer to use a single event sheet that works in both C2 and C3.

    I would also prefer to not have to learn both the C2 and the C3 javascript SDK.

  • Hi there Construct community!

    I am looking to create a web page that will allow users to upload an image, do some processing on that image, then download the processed version as a file. This processed version will be in a text-based format, either .svg or .nc as G-Code for a pen plotter or laser engraver.

    I am confident I can create the text of the file. How do create the file itself and invoke a download of it to the user’s hard drive?

  • Here is a sample of how I am using the UserMedia object right now:

    https://nerdislandstudios.com/videoTest-Test3/

    If you were to drop a ball in front of your phone's camera, you would see a substantial amount of motion blur at the standard 30 fps mode. If you enable the highest frame rate on your camera and record a "slow motion" video the resulting video frames have significantly less motion blur.

    Ashley, would this be a feature request? Maybe the ability to request higher frame rates in the UserMedia -> Request Camera action?

  • Is it possible to request a high frame rate in the UserMedia object in Construct 3? I am looking to request the highest framerate possible for the device.

    On my phone this is 240 fps on the rear camera. On my iPad this is 120 fps.

  • Eureka! I have tried 3 approaches. The last two both work correctly:

    Non-working approach: try to seek to a time, then play a video frame, pausing at that frame.

    I'm assuming that the reason this approach doesn't work it that due to the way video encoding works it is impossible to seek to an individual frame.

    Working Approach #1 - Snapshot live camera feed by capturing a frame every 0.1 seconds from UserMedia.takeSnapshot() action. Save this to a frame in a sprite.

    Working Approach #2 - Snapshot a video from the Camera Roll by playing a video with the video object and taking a System.snapshot() every 0.1 seconds. Save this snapshot to a frame in a sprite.

    Please note that Working Approaches #1 and #2 above only run properly if your device can save the snapshots quickly enough. This works great on my phone and iPad, but doesn't work at all on my 2013 Macbook Air.

  • I am looking to create a video scrubber in Construct 3 that can load a very short (1 or 2 second long) video then scrub through the video frame-by-frame. So far I am able to do the following:

    1. Load a video to the Video Plugin using the File Chooser plugin.

    2. Play the video immediately upon load.

    When I add events to set the playback time, it seems to seek to a random time in the future, usually 2 seconds or so, rather than incrementing a single frame at a time.

    Is Video.setPlaybackTime() not accurate enough to advance a single frame?

    ALTERNATIVE APPROACH

    If the approach above doesn't work, does anyone know if there is a way to save the frames of an encoded video to a bunch of sprite frames completely client-side? I know this can be done on a server in php or Node.js, but I don't want to bog down my server with a bunch of video conversion requests.

    I also don't want to go to Unity3d to write code for this.

    Thank you so much for your help!

  • Sure! It has been three years since I looked at it, and don’t currently have a computer that runs Construct 2. My memory might be a little rusty.

  • I totally disagree about it not being “true 3D”. It is 3D in every sense. It just doesn’t have all of the amenities of a modern first person engine like Unreal or CryEngine, but it is more than adequate for things like 3D puzzle games.

    OIMO.js physics works great! I found it more intuitive than the work I’ve been doing for the past 3 years in Unity’s implementation of PhysX. Kudos to Quazi for the great job he did with Q3D’s physics.

  • I don’t know about video tutorials, but have you tried the written tutorial with pictures I linked back a few pages ago? I tried to keep the descriptions as simple as I could.

  • Oh my gosh! I totally forgot we made that video! What a find! 😂