How do I detect red color object in opened camera ?

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi Friends,

    I need help in creating a game using construct 2 camera. When user opens camera and any red color object is seen through camera. It will show a sticker. So whole idea is camera should detect color and do something. How to do this?

    I am trying to detect color in real time video. Here is sample of what I want to do

    https://trackingjs.com/examples/color_camera.html

    Steps

    1 open camera

    2 select colors from check box that u want to get detected and then u can see it shows boxes of detected color.

    Can we do like that in construct 2?

    Regards,

    Jatin

  • Hi, you don't have to detect a color to do what you want. You can simply detect a specific object which happens to be red. There are several ways to accomplish this:

    • If the red object is an independent object it can be simply detected by its name
    • If the red object is a clone of an existing object you can give it an instance variable Red = 1, Red = 0 for other objects

    Next for the detection area, if it is the entire area there is a "is visible" feature that you can use and/or right click on that after adding and click Reverse which then means "is not visible".

    Another way is to detect using the distance from the camera object. So if it is within say 300 pixels then you consider it detected. A simple distance formula should easily work for this.

    Best of luck,

    COSMOS

  • Hi, you don't have to detect a color to do what you want. You can simply detect a specific object which happens to be red. There are several ways to accomplish this:

    - If the red object is an independent object it can be simply detected by its name

    - If the red object is a clone of an existing object you can give it an instance variable Red = 1, Red = 0 for other objects

    Next for the detection area, if it is the entire area there is a "is visible" feature that you can use and/or right click on that after adding and click Reverse which then means "is not visible".

    Another way is to detect using the distance from the camera object. So if it is within say 300 pixels then you consider it detected. A simple distance formula should easily work for this.

    Best of luck,

    COSMOS

    I believe he's talking about an actual, physical, object he wants to be detected through the actual image capture of an actual camera. Not the game camera, not a sprite, virtual, object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I believe he's talking about an actual, physical, object he wants to be detected through the actual image capture of an actual camera. Not the game camera, not a sprite, virtual, object.

    Oh - that's totally next level stuff for me

    I didn't even know we can do stuff like that in C2

  • I'm not sure you can do that. I know it was possible in Flash. You just got the image and scanned it for a certain rgb. Not trivial, but feasible. Not sure it can be done with Construct 2.

  • > Hi, you don't have to detect a color to do what you want. You can simply detect a specific object which happens to be red. There are several ways to accomplish this:

    >

    > - If the red object is an independent object it can be simply detected by its name

    > - If the red object is a clone of an existing object you can give it an instance variable Red = 1, Red = 0 for other objects

    >

    > Next for the detection area, if it is the entire area there is a "is visible" feature that you can use and/or right click on that after adding and click Reverse which then means "is not visible".

    >

    > Another way is to detect using the distance from the camera object. So if it is within say 300 pixels then you consider it detected. A simple distance formula should easily work for this.

    >

    > Best of luck,

    > COSMOS

    >

    I believe he's talking about an actual, physical, object he wants to be detected through the actual image capture of an actual camera. Not the game camera, not a sprite, virtual, object. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Hi Bruno. thanks for replying and Yes you r correct. I am trying to detect color in real time video. Here is sample of what I want to do

    https://trackingjs.com/examples/color_camera.html

    Steps

    1 open camera

    2 select colors from check box that u want to get detected and then u can see it shows boxes of detected color.

    Can we do like that in construct 2?

  • You can't do this with standard C2 events, but it's possible with JS code.

    Here is a somewhat similar plugin that detects faces in images.

    viewtopic.php?t=72970&start=0

    https://github.com/JohnnySheffield/C2_P ... facedetect

    If you are familiar with JS, you can probably modify this plugin for color detection using tracking.js library from the link you posted.

  • You can't do this with standard C2 events, but it's possible with JS code.

    Here is a somewhat similar plugin that detects faces in images.

    viewtopic.php?t=72970&start=0

    https://github.com/JohnnySheffield/C2_P ... facedetect

    If you are familiar with JS, you can probably modify this plugin for color detection using tracking.js library from the link you posted.

    I already got facedetect plugin but due to no knowledge of JS I can't modify the code to detect colors in camera. If you can help me out in this that would be really great.

  • Hi Anyone can help me out in this?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)