Home>
I want to send the marker center coordinates to MarkerTracking using the marker angular coordinates obtained with LiveSketchScript.
At present, you can refer to each variable itself, but you cannot know how to handle point2f and you cannot assign a numerical value.
LiveSketchScript side
mt.WStartp = corners;
I want to put the center coordinates in thepart and put it in WStartp.
If i run this way
OpenCvSharp.Point2f [] []
UnityEngine.Debug: Log (Object)
MarkerTracking: Update () (at Assets/MarkerTracking.cs: 26)
It just comes out on the console and doesn't contain any numbers.
How can I get and calculate the contents of point2f?
Thank you.
using OpenCvSharp;
using OpenCvSharp.Demo;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarkerTracking: MonoBehaviour
{
LiveSketchScript LSS;
public Point2f [] [] WStartp, WEndo, CStartp, CEndp;
// DefaultTrackableEventHandler DTE;
bool Count = false;
Vector2 WposST, WposED, CposST, CposED, Ccal;
float Dist;
// Start is called before the first frame update
void Start ()
{
// DTE = this.gameObject.GetComponent<DefaultTrackableEventHandler>();
}
// Update is called once per frame
void Update ()
{
if (WStartp! = null)
{
Debug.Log (WStartp);
}
if (Input.GetKeyDown ("return"))
{
Debug.Log (WStartp);
if (Count == false)
{
// WposST = GameObject.Find ("WorldMarker"). Transform.position;
// CposST = this.gameObject.transform.position;
Count = true;
}
else if (Count)
{
Ccal = CposED-(WposED-WposST);
Dist = Vector3.Distance (CposST, Ccal);
Debug.Log (Dist);
Count = false;
}
}
if (Count)
{
WposED = GameObject.Find ("WorldMarker"). Transform.position;
CposED = this.gameObject.transform.position;
}
}
}
namespace OpenCvSharp.Demo
{
using UnityEngine;
using OpenCvSharp;
using Aruco;
public class LiveSketchScript: WebCamera
{
MarkerTracking mt;
protected override void Awake ()
{
base.Awake ();
this.forceFrontalCamera = true;
var thread_mgr = GameObject.Find ("SampleRaw") as GameObject;
mt = thread_mgr.GetComponent<MarkerTracking>();
}
// Our sketch generation function
protected override bool ProcessTexture (WebCamTexture input, ref Texture2D output)
{
// Create default parameres for detection
DetectorParameters detectorParameters = DetectorParameters.Create ();
// Dictionary holds set of all available markers
Dictionary dictionary = CvAruco.GetPredefinedDictionary (PredefinedDictionaryName.Dict6X6_250);
// Variables to hold results
Point2f [] [] corners;
int [] ids;
Point2f [] [] rejectedImgPoints;
// Create Opencv image from unity texture
Mat mat = Unity.TextureToMat (input);
// Convert image to grasyscale
Mat grayMat = new Mat ();
Cv2.CvtColor (mat, grayMat, ColorConversionCodes.BGR2GRAY);
// Detect and draw markers
CvAruco.DetectMarkers (grayMat, dictionary, out corners, out ids, detectorParameters, out rejectedImgPoints);
CvAruco.DrawDetectedMarkers (mat, corners, ids);
mt.WStartp = corners;
output = Unity.MatToTexture (mat);
return true;
}
}
}
-
Answer # 1
Related articles
- c # - can't get variable of script attached to ui in another ui
- c # - i want to call a method of another script in unity, but it doesn't work
- c # - [unity] when i try to refer to another script with getcomponent, an error occurs
- c # - i want to inherit enum with another script
- c # - [unity] i want to uncheck firstpersoncontroller with a script
- i want to reference a bool value in a script of another object
- python 3x - i want to run another python script from a python script
- google apps script - copy gas master sheet to another spreadsheet + grant edit authority cause of code error in openbyid part
- google apps script - copy gas master sheet to another spreadsheet + grant editing authority cause of code error
- google apps script - [gas] i want to display another sheet after executing the script
- google apps script - how to run another spreadsheet script from your own library side with gas
- how to find the center coordinates of a three-dimensional circle
- c # - error by assets received from another person in unity
- c # - object duplication script in unity 2d
- unity - materialization of variables in another script
- c # - [unity] i am changing the value of a public variable from another script, but the value seen from the script with that pub
- c # - what are the inherited members in the unity script reference?
- c # - i want to programmatically put the character variable set in another script into text (script)
- c # - [unity] how to make a script that executes processing after a certain period of time
- c # - i want to find the angle of an arc from the start point, end point, center point, and direction
Related questions
- c # - i want to run unity: transformtranslate using rigidbody
- c # - [unity] an unintended transition occurs in the state transition of animator controller
- c # - about unity hinge joint script
- c # - i want to display the trajectory prediction line when throwing a unity3d grenade (provisional)
- c # - [unity] i want to make the camera follow the player in photon, but if there are multiple players, it will not follow
- c # - i want to move smoothly to where i pressed with the unity mouse
- c # - error in nav mesh agent
- c # - unity) how to convert the path passed to resourcesload ()
- c # - if you hit a bullet at a close distance, the speed will be 0
- c # - i want to slowly rotate the model to a fixed angle when the flag is set, and slowly return it to the original angle when t
It was not an error, just a marker was not recognized